function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Beto Carvalho 11Beto Carvalho 11 

Query WorkflowRule filtering by metadata (e.g. active, triggerType)

I'd like to find all Workflow Rules which run on Object X, are active, and e.g. trigger on create only. Using Tooling API I can get this far, of course:
Select ID, Name
From WorkflowRule
Where TableEnumOrId = 'Opportunity'
I'd like something like this (dream query):
Select ID, Name
From WorkflowRule
Where TableEnumOrId = 'Opportunity' AND metadata.triggerType = 'onCreateOnly' AND metadata.active = true
Of course I made up the above syntax (after TableEnumOrId = 'Opportunity'). 

Object = WorkflowRule
TableEnumOrId = 'Opportunity'
Metadata > triggerType = onCreateOnly
Metadata > active = true

Any way to run this query on Developer Console, Workbench REST Explorer or something of the sort?
VinayVinay (Salesforce Developers) 
Hi Beto,

You can try below snippet.

>> Open workbench.
>> Navigate to Rest Explorer.

 For all workflow rules (Including inactive )

/services/data/v47.0/tooling/query?q=Select+Id,Name,TableEnumOrId+From+WorkflowRule

For all workflow rules by object.

/services/data/v47.0/tooling/query?q=Select+Name,TableEnumOrId+From+WorkflowRule+where+TableEnumOrId='Account'

Also you cannot use 'metadata.triggerType = 'onCreateOnly' AND metadata.active = true' in SOQL query.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. 

Thanks,
Vinay Kumar