How can I get list of all workflow rules using apex? I want to retrieve names of all workflow rules using apex code.

3 Answers 3


I haven't done it myself, but I think you could call the metadata api from apex and than process the output.


  • 4
    The metadata API returns zip files though, so even if you get the WSDL to be parsed into an apex class there's no way to really handle the replies as there's no API for working with zip files in apex. Sep 1, 2012 at 19:57
  • Thanks @ca_peterson so I think there is no way to get list of workflows itself in apex. Thanks for your inputs
    – Manisha
    Sep 3, 2012 at 16:27
  • In all fairness, my answer was a bit shortsighted, Adam's is more accurate. Sep 4, 2012 at 15:17
  • 1
    Do also take a look at my answer, I have managed to get retrieve to work and unzip the results. The demo in the github repo shows layouts, however it is a small change to list and retrieve workflows. :-) Nov 10, 2012 at 20:28

Unfortunately I believe you would need to use the Metadata API for this, which requires processing outside of Apex (from Heroku in Python/Ruby, for example). However, if there's a way to get this done from within Apex, I'll be really happy to learn about it!

  • I think I can call metadata API from Apex (WSDL Import and all ).. but is it good practice to do so ? please suggest.
    – Manisha
    Sep 1, 2012 at 18:43
  • 4
    Accessing the Metadata API from within Apex is not supported out of the box, but some have tried (with apparently some success) to do this: boards.developerforce.com/t5/Apex-Code-Development/…
    – Adam
    Sep 1, 2012 at 19:14

I've been successful in getting parts of the Metadata API working from Apex using the WSDL2Apex tool and a few tweaks! However the listMetadata operation in respect to Workflow does not quite return what you would expect. Take a look at this answer for more info. Hope this helps!


  • I've enhanced the Apex library referenced in the github repo, it now does a Metadata Retrieve. Meaning you can list the Workflows using listMetadata and then use retrieve on each to get the actual list of rules from within! The example given uses Layouts but you can easily change it to Workflow component types. Hope this helps! github.com/financialforcedev/apex-mdapi#metadata-retrieve-demo Oct 16, 2012 at 0:30
  • that might help me too, thanks for the github code. Let me try and then I can contribute to the repo. Nov 10, 2012 at 8:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .