Fetch list of workflows in state X


Let’s say there is a workflowType which contain a Enum X with states as {A, B, C}, where value of X gets updated via some signals. There are millions of workflows running with this workflowType.

I want to list all workflows running with enum State B. How would one go about implementing this?

You could do this via advanced visibility and search attributes. Each time your workflow updates X upsert a custom search attribute value to A,B, or C. Then you can run visibility queries via tctl or sdk apis for example:

tctl wf list -q "ExecutionStatus='Running' AND MyCustomStateVal='B'"

Hope this helps.