You need to sign in to do that
Don't have an account?
Creating a new approval process step dynamically
Hi all,
I have the following code
I have the following code
public static void submitSplitApprovalStepOne(Id recordId, String firstApprover){ approval.ProcessSubmitRequest step1 = new Approval.ProcessSubmitRequest(); step1.setComments('The approver passed is: ' + firstApprover); step1.setObjectId(recordId); step1.setNextApproverIds(new Id[] {firstApprover}); approval.ProcessResult result = Approval.process(step1); }
When this method is called and passed a record for an object with a pre redfined approval process activated on it, it successfully creates a step and submits it to the first Approver ID.
How can I extend this code so that I can add another step and set the approver via apex? I know I'll probably have to query the ProcessInstance table to track my job, but I'm not sure how to add a step with an approver via code.
You can try this one.If it works then please let me know.
Thanks,
Sailee.
Can you highlight the parts that allow this?
Kind Regards,
Sam Cousins
If I understood it correctly, you need to dyanamically provide the appover Ids for the approval process.
For this you can ceate custom user lookup fields on object and use them in approval process. While creating a record populate these fields with user Id. It will auto assign user as approver.
Thanks,
Ishwar