process()

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.

Syntax

ProcessResult = sfdc.process( processType processRequest[])

processType can be either ProcessSubmitRequest or ProcessWorkitemRequest

Usage

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.

Sample Code—Java

public ProcessResult[] doProcessSample(String comments, String id, String[] approverIds) throws ApiFault { 
    ProcessResult[] processResults; 
    ProcessSubmitRequest request = new ProcessSubmitRequest(); 
    request.setComments(comments); 
    request.setNextApproverIds(approverIds); 
    request.setObjectId(id); 
    try { 
        //calling process on the approval submission 
        processResults = binding.process(new ProcessSubmitRequest[]{request});  
        for (ProcessResult processResult : processResults) { 
                if(processResult.getSuccess()){ 
                    if(xconfig.isTraceMessage()){ 
                        log.debug("Approval submitted for: " + id + ", approverIds: " + 
                                   approverIds.toString() + " successful."); 
                        log.debug("Process Instance Status: " + 
                                   processResult.getInstanceStatus()); 
                    } 
                } else{ 
                    log.error("Approval submitted for: " + id + ", approverIds: " + 
                                approverIds.toString() + " FAILED."); 
                    log.error("ERRORS: " + processResult.getErrors().toString()); 
                } 
        } 
    } catch (Exception e) { 
       e.printStackTrace(); 
    } 
    return processResults; 
} 

Sample Code—C#

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());
    }
}

ProcessSubmitRequest Arguments

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.

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 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.

Response

ProcessResult[]

Faults

ALREADY_IN_PROCESS

NO_APPLICABLE_PROCESS

See Also:
API Call Basics
© Copyright 2000-2008 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.