[SalesForce] Metadata API support for Approval Processes

EDIT:

I have search online and could not find any resource that talks about how to get metadata for Approval Process

I know that the approval process stores in the ProcessDefinition object but what I'm trying to find is the Entry Criteria that user have selected for the Approval Process how do I get this information in metadata api (workbench)

Here is the screen shot for ref:

enter image description here
EDIT END

I'm trying to execute the following rest explorer in Workbench and getting this error, what I'm doing wrong here?

/services/data/v40.0/tooling/query?q=SELECT+Id+FROM+ProcessDefinition

INVALID_TYPE message: sObject type 'ProcessDefinition'
is not
supported. errorCode: INVALID_TYPE

Best Answer

I suspect you just want a normal SOQL query rather than a Tooling API query.

The following ran against the SOAP Partner API no problem.

Select Id, Name From ProcessDefinition

It also worked in the Developer Console, which means it was executed against the REST API. enter image description here

Request URL:https://foo-dev-ed.my.salesforce.com/services/data/v40.0/query/?q=Select%20Id%2C%20Name%20From%20ProcessDefinition&columns=true&_=111111111111

See also:


Update for subsequent question

To get the Entry Criteria for the approval process you will need to go to the Metadata API. See ApprovalProcess and the associated entryCriteria of type ApprovalEntryCriteria.

Getting to that in Apex will require a bit of work. You could try the Apex Wrapper Salesforce Metadata API. There is also the official Apex Metadata API, but that doesn't have access to the approval processes yet (as at Summer '17). Try raising the use case in the success community or as an idea.

Related Topic