Why do you have to exclude the current WO by its status? Can you just exclude it with WO id instead. When you say "I get count from DB" do you mean your agent get count from DB or is it a completely different process?
We have to resolve complete the WO when the count is not exceeded. Otherwise we have to send the WO to some pre review if it exceeds the count. User sets the count value somewhere, so on each request in the flow we check the count is exceeding or not.
For same day request this is working fine, but for future dated requests, let's say we have 10 future dated requests with Pending-FutureDate status in DB. On processing the first request I am updating the status to Pending-Review and getting the count from DB. Still it is getting the count as 10 instead of 9.
All Future dated requests waits at Assignment shape with BlankFlowAction. Agent just kicks off the flow by processing the BlankFlowAction. Updating the status and getting the count are part of the flow.
For eg: If user sets the count value as 5, then first 5 requests which wakes up one after the other should be resolved completed. The requests from 6 to 10 should go to some approval.