1

I am trying to run the following query in my developer console (using tooling api): SELECT Id,Name,NamespacePrefix,Metadata FROM WorkflowRule but get an error saying 'An unexpected error occurred.'

It works fine if I remove the metadata field and run the following query: SELECT Id,Name,NamespacePrefix FROM WorkflowRule

Am I missing anything? Please help.

Thanks!

  • When I run the second query from the developer console "query editor" I get "sObject type 'WorkflowRule' is not supported.". (Perhaps I am missing a step in this to use the "tooling api"; please add that step to the question if I am.) – Keith C Oct 13 '14 at 7:59
  • There will be a checkbox 'use tooling api' towards the bottom of the screen that needs to be checked. – Priyanshi Agrawal Oct 14 '14 at 11:33
  • @PriyanshiAgrawal Where you able to get through metadata information too using tooling api query ? – Chirag Mehta Dec 26 '14 at 15:11
  • @ChiragMehta Yes, I was able to get the metadata information after the last Salesforce release. – Priyanshi Agrawal Dec 27 '14 at 18:22
2

I know this is quite old now, but I'll post this here for those who still come across this question:

You can only retrieve the metadata from one workflow rule at a time. If you look at the Salesforce "Workflowrule" documentation under the tooling API at https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_workflowrule.htm#!, you will notice that under Metadata it says

Query this field only if the query result contains no more than one record. Otherwise, an error is returned. If more than one record exists, use multiple queries to retrieve the records. This limit protects performance.

As such, in order to return that Metadata, your query should contain a where clause so that it only returns ONE and ONLY ONE workflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.