Approval Process using Apex

In order to use apex code to submit the record for Approval process, we have to first create Approval process in Create --> Workflow & Approvals.

Sample code:

    void submit(Id localId)
        // Create an approval request for the account
        Approval.ProcessSubmitRequest req1 =
            new Approval.ProcessSubmitRequest();
        req1.setComments('Submitting request for approval.');
        // Submit the approval request for the account
        Approval.ProcessResult result = Approval.process(req1);
        // Verify the result
            'Pending', result.getInstanceStatus(),
            'Instance Status'+result.getInstanceStatus());       


Visit the below link to get more details|StartTopic=Content%2Fapex_ProcessRequest.htm|SkinName=webhelp


No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit