I read one response from you is export all data to eclipse and then use metadata api to get list of all workflow rules.

I have similar requirement where i need to pull List of workflow rules using metadata api.

Can some one point me to any example or sample code?

1 Answer 1


Metadata API

This can be accomplished using the listMetadata operation on the Metadata API.

This call retrieves property information about metadata components in your organization. Data is returned for the components that match the criteria specified in the queries parameter. The queries array can contain up to three ListMetadataQuery queries for each call. This call supports every metadata type: both top-level, such as CustomObject and ApexClass, and child types, such as CustomField and RecordType.

There is some sample Java code at the bottom of the documentation.

If your wanting to use Apex there is also a wrapper library here you can use, along with a sample here. The following is an Apex Metadata API (wrapper) example, but you'll find it in alignment with the requirement from other langauges such as Java and .Net.

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

Tooling API

There also seems to be support for querying via the Tooling API the Workflow object, which will likely give you more information than just the FileProperties. There is also an Apex wrapper for this API here.

You must log in to answer this question.

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