Submits an array of approval process instances for approval, or processes an array of approval process instances to be approved, rejected, or removed. For more information, see Set Up an Approval Process in Salesforce Help.
Use the process() call to perform either of the following two tasks:
Submit an array of objects to the approval process. Objects cannot already be in an approval process when submitted. Use the ProcessSubmitRequest signature.
Process an object that has been submitted to the approval process by performing an approval action (Approve or Reject). Use the ProcessWorkitemRequest signature.
Requests are processed and a ProcessResult is returned with the same process instances as sent in the request.
The failure of a particular record doesn’t cause failure of the entire request.
Because you can fire Apex triggers with this call, you can update fields that contain strings.
Starting with API version 15.0, if you specify a value for a field that contains a string, and the value is also too large for the field, the call fails, and an error is returned. In previous versions of the API the value was truncated and the call succeeded. If you wish to keep the old behavior with versions 15.0 and later, use the AllowFieldTruncationHeader SOAP header.
Note
Sample Code—Java
This sample accepts the ID of the sObject to process the approval for and an array containing the IDs of the next approvers. It creates a process approval request and submits it for approval. Finally, it parses the results of the process() call.
This sample accepts the ID of the sObject to process the approval for and an array containing the IDs of the next approvers. It creates a process approval request and submits it for approval. Finally, it parses the results of the process() call.
1public void processRecords(String id, String[] approverIds)2{3 ProcessSubmitRequest request = new ProcessSubmitRequest();4 request.comments = "A comment about this approval.";5 request.objectId = id;6 request.nextApproverIds = approverIds;7 try8 {9 ProcessResult[] processResults = binding.process(10 new ProcessSubmitRequest[] { request });11 foreach (ProcessResult processResult in processResults)12 {13 if (processResult.success)14 {15 Console.WriteLine("Approval submitted for: " + id + ":");16 for (int i = 0; i < approverIds.Length; i++)17 {18 Console.WriteLine("\tBy: " + approverIds[i] + " successful.");19 }20 Console.WriteLine("Process Instance Status: "21 + processResult.instanceStatus);22 }23 else24 {25 Console.WriteLine("Approval submitted for: " + id26 + ", approverIds: " + approverIds.ToString() + " FAILED.");27 Console.WriteLine("Error: "28 + processResult.errors.ToString());29 }30 }31 }32 catch (SoapException e)33 {34 Console.WriteLine("An unexpected error has occurred: " +35 e.Message + "\n" + e.StackTrace);36 }37}
ProcessSubmitRequest Arguments
Name
Type
Description
comments
string
Text that you want to accompany the submission. Don’t reference merge fields or formula expressions. Submission comments appear in the approval history for the specified record. This text also appears in the initial approval request email if the template uses the {!ApprovalRequest.Comments} merge field.
nextApproverIds
ID
If the process requires specification of the next approval, the ID of the user to be assigned the next request.
objectId
ID
The record to submit for approval.
processDefinitionNameOrId
string
The unique name or ID of the specific approval process to which you want the record to be submitted. The process must have the same object type as the record you specified in objectId. Required if skipEntryCriteria is true.
skipEntryCriteria
boolean
If true, the record isn’t evaluated against the entry criteria set on the process that is defined in processDefinitionNameOrId.
submitterId
ID
The ID for the user who submitted the record for approval. The user receives notifications about responses to the approval request. The user must be one of the allowed submitters for the process.
ProcessWorkitemRequest Arguments
Name
Type
Description
action
string
For processing an item after being submitted for approval, a string representing the kind of action to take: Approve, Reject, or Removed. Only Salesforce admins can specify Removed. If the Allow submitters to recall approval requests option is selected for the approval process, the submitter can also specify Removed.
comments
string
Text that you want to accompany the submission. Don’t reference merge fields or formula expressions. Submission comments appear in the approval history for the specified record. This text also appears in the initial approval request email if the template uses the {!ApprovalRequest.Comments} merge field.
nextApproverIds
ID
If the process requires specification of the next approval, the ID of the user to be assigned the next request.