Recently I'm working on building something for developers/administrators - a handy 100% force.com app allowing to search metadata. Currently this app allows you to quickly search (from sidebar) custom code components (Pages, Apex Classes, Components and Apex Triggers).

Now I'm trying to add feature to search workflows or validations or email templates or fields etc, but stuck with some apex limitations. There's no APEX or direct api (methods) to search(query) above components. What are the options here for me?

  1. Use Metadata WSDL, parse it as apex class and then use that to retrieve/search the necessary component list ??
  2. Use Metadata REST API ??

  3. Crawler in VF using JS (just a wild hacky thought, not even sure if this's possible)

  • 3
    This isn't a direct answer to your question - the metadata API answers are correct - but for anyone looking at this question and wondering how to do it themselves without using the API directly, the easiest way is to use the Force.com IDE, download all selectable metadata, and then do a full-text search (ctrl-H). I've worked with several people who did not know/realize this.
    – jkraybill
    Sep 25, 2012 at 8:50
  • @jkraybill - Force.com IDE is obvious choice for developers, but not for admins. Also when you are moving or in remote location (ie when you dont have IDE on the machine) then we need some native (force.com) way of doing it. That's what I'm trying to build :) Sep 25, 2012 at 13:27
  • Sound great, I support it! We need more tooling in general, I look forward to seeing your app. A native full-text metadata search would be great.
    – jkraybill
    Sep 25, 2012 at 13:35
  • yes that's what I'm tyring upto. Sep 25, 2012 at 15:35
  • When clients have wanted to do workflow cleanups one approach that has been fruitful has been to export the data into Eclipse and use the raw metadata to generate a CSV that includes the workflow rules. You can then email the CSV to the appropriate admins. Nov 6, 2012 at 15:41

3 Answers 3


UPDATE: 11th Nov, I discovered the WorkflowRule (as apposed to the Workflow) metadata type! Combined with the ValidationRule metadata type. This means that the Metadata listMetadata API call now returns exactly the two lists you need to implement your search tool.

This will allow you to list the Validation Rules and Workflow Rules from Apex.

MetadataService.MetadataPort service = MetadataServiceExamples.createService();     
List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();        
MetadataService.ListMetadataQuery queryWorkflow = new MetadataService.ListMetadataQuery();
queryWorkflow.type_x = 'WorkflowRule';
MetadataService.ListMetadataQuery queryValidationRule = new MetadataService.ListMetadataQuery();
queryValidationRule.type_x = 'ValidationRule';
MetadataService.FileProperties[] fileProperties = service.listMetadata(queries, 25);
for(MetadataService.FileProperties fileProperty : fileProperties)

For more information and the MetadataService and MetadataServiceExamples class used in the above code. Please take a look at this Github repo and Readme file.

  • let me check this and get back to you, anyhow thanks a lot for such detailed post. Oct 18, 2012 at 5:25
  • Your welcome Chirag! Hope you get it sorted. If you do or need a hand, happy to help! Maybe we can build a small sample and commit to the repo as well? Oct 23, 2012 at 7:11
  • Sure. can you please drop me an email at jain.chirag[at]gmail.com Oct 23, 2012 at 12:00
  • Just updated my answer, while exploring the 'describeMetadata' Metadata API, I discovered that you can ask the listMetadata API for WorkflowRule's! The snippet above should now be spot on for what you've asked for. Have fun! Nov 11, 2012 at 18:31
  • Your very welcome! Lots of possibilities lie ahead with this. Glad to see this seems to have answered your question... ;-) Nov 20, 2012 at 9:08

Not sure for others but for Email Templates you can use


  • yes I realized the same after posting above, that emailtemplates too are available in a object/table form, so soql will help here. Thanks for your answer. However my major conern is on how to search the workflows and validation rules. Sep 25, 2012 at 8:26

I would go with the metadata REST api over the SOAP one as it will be significantly easier to deal with in apex and salesforce will be adding all the metadata components that are exposed in the SOAP api as time passes.

  • yes metadata REST API is obvious choice even for me :) Sep 25, 2012 at 8:27
  • I'm not sure I understood your question then. Sep 25, 2012 at 17:59
  • what part is confusing? as said in main post, I'm trying to develop visualforce page which allows to search for metadata (pages, classes...validation rules, workflows etc).. So to search pages, classes.. I had to do simple soql on their respective objects. But for validation rules or workflows there's no such object available, so the only way to get the list of validation rules or wf is to use metadata api (via REST or SOAP). Hope that clears your confusion. Sep 26, 2012 at 3:42
  • Yep I would love to use the REST API as well. Unfortunately the REST API is read only in Pilot. And I've been told the GA read/write version is someway away sadly. So it depends on how long your prepared to wait I guess. Oct 12, 2012 at 21:13
  • That's sad thing, are you sure its in Pilot yet? Oct 18, 2012 at 5:25

You must log in to answer this question.

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