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 “Getting Started with Approval Processes” in the Salesforce online help.
ProcessResult = connection.process( processType processRequest[])
processType can be either ProcessSubmitRequest or ProcessWorkitemRequest
Use the process() call to perform either of the following two tasks:
Requests are processed and a ProcessResult is returned with the same process instances as sent in the request.
The failure of a particular record will not cause failure of the entire request.
public void processRecords(String id, String[] approverIds) { ProcessSubmitRequest request = new ProcessSubmitRequest(); request.setComments("A comment about this approval."); request.setObjectId(id); request.setNextApproverIds(approverIds); try { ProcessResult[] processResults = connection.process(new ProcessSubmitRequest[]{request}); for (ProcessResult processResult : processResults) { if (processResult.isSuccess()) { System.out.println("Approval submitted for: " + id + ":" ); for (int i = 0; i < approverIds.length; i++) { System.out.println("\tBy: " + approverIds[i] + " successful." ); } System.out.println("Process Instance Status: " + processResult.getInstanceStatus()); } else { System.out.println("Approval submitted for: " + id + ", approverIds: " + approverIds.toString() + " FAILED." ); System.out.println("Error: " + processResult.getErrors().toString()); } } } catch (ConnectionException ce) { ce.printStackTrace(); } }
private void doProcessSample(String id, String[] approverIds) { ProcessResult[] processResults; ProcessSubmitRequest request = new ProcessSubmitRequest(); request.objectId = id; try { processResults = binding.process(new ProcessSubmitRequest[] { request }); for (int i = 0; i < processResults.Length; i++) { ProcessResult processResult = processResults[i] ; if (processResult.success) { Console.WriteLine("Approval submitted for:" + id + " successful."); } else { Console.WriteLine("Approval submitted for:" + id + " FAILED."); Console.WriteLine("Errors: " + processResult.errors.ToString()); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
| Name | Type | Description |
|---|---|---|
| objectId | ID | The object to submit for approval, for example, an Account, Contact, or custom object. |
| nextApproverIds | ID[] | If the process requires specification of the next approval, the ID of the user to be assigned the next request. |
| comment | string | The comment to add to the history step associated with this request. |
| 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 Remove. Only system administrators can specify Remove. If the Allow submitters to recall approval requests option is selected for the approval process, the submitter can also specify Remove. |
| nextApproverIds | ID[] | If the process requires specification of the next approval, the ID of the user to be assigned the next request. |
| comment | string | The comment to add to the history step associated with this request. |
| workitemId | ID | The ID of the ProcessInstanceWorkitem that is being approved, rejected, or removed. |