1

I've recently been asked by a customer to mimic the 'Submit for Approval' button on the lead form via the api for various leads. I can see that this is a standard button and I assume that the process behind it is also standard(?). Does anyone know what api call would allow me to do this?

Any light shed on this would be helpful.

Thanks in advance.

1 Answer 1

2

You can use Force.com REST APIs to get the list of All Approval Processes, Submit a Record for Approval, approve a Record, reject a Record or for bulk Approvals. The Getting Started with Force.com REST API guide has detailed documentation with examples and you might want to check it out.

Use the Process Approvals resource to submit a record or a collection of records for approval. Each call takes an array of requests. The entity must support an approval process and an approval process must have already been defined.

In the following example, the record "001D000000I8mIm" is submitted for approval process "PTO_Request_Process" by skipping its entry criteria on behalf of submitter "005D00000015rZy."

Example request body submit.json file

 {
    "requests" : [{
    "actionType": "Submit",
    "contextId": "001D000000I8mIm",
    "nextApproverIds": ["005D00000015rY9"],
    "comments":"this is a test",
    "contextActorId": "005D00000015rZy",
    "processDefinitionNameOrId" : "PTO_Request_Process",
    "skipEntryCriteria": "true"}]
    }

Example JSON response body

    [ { 
      "actorIds" : [ "005D00000015rY9IAI" ],
       "entityId" : "001D000000I8mImIAJ",
       "errors" : null,
       "instanceId" : "04gD0000000Cvm5IAC",
       "instanceStatus" : "Pending",
       "newWorkitemIds" : [ "04iD0000000Cw6SIAS" ],
       "success" : true } ] 
3
  • Thank you, but what is the process that is called as it looks like the 'Submit for Approval' button is a standard button. How can I determine what process I should be calling? Are all these parameters needed when the button is clicked? Presumably things like 'Next Approver ID' is not something I should have to worry about but that should be built into the process. Apr 28, 2015 at 10:57
  • As a side note, I'm using the SOAP API. Apr 28, 2015 at 11:04
  • For the SOAP API, looks like if you just provide the comments and the objectId it should work as well. You might want to check this: blog.jeffdouglas.com/2010/01/04/… and salesforce.com/developer/docs/api/Content/… Apr 28, 2015 at 12:00

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.