Created
July 20, 2017 09:43
-
-
Save sfdcfanboy/6976c9cf0bbd579ad35c283a6767f6e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApprovalProcessor { | |
webservice void submitAndProcessApprovalRequest() { | |
// Create an approval request for the account | |
Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest(); | |
req1.setComments('Submitting request for approval.'); | |
req1.setObjectId(a.id); | |
// Submit on behalf of a specific submitter | |
req1.setSubmitterId(user1.Id); | |
// Submit the record to specific process and skip the criteria evaluation | |
req1.setProcessDefinitionNameOrId('PTO_Request_Process'); | |
req1.setSkipEntryCriteria(true); | |
// Submit the approval request for the account | |
Approval.ProcessResult result = Approval.process(req1); | |
// Verify the result | |
System.assert(result.isSuccess()); | |
System.assertEquals( | |
'Pending', result.getInstanceStatus(), | |
'Instance Status'+result.getInstanceStatus()); | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment