0

We have a requirement wherein we need the approve or reject button on the a record page. The actual same button from the approval request page. So when we click the approve button on the Quote page this should show the popup modal to input a comment and finish the approval of the record. Same for the reject button. We are to put the buttons on a custom component but we aren't exactly sure how to handle the button. Is this possible?

1 Answer 1

1

Just found out one way to do this is through apex. On the approve or reject button handle it by calling out an apex method and the code should be like below:

Approval.ProcessWorkitemRequest approvalProcess = new Approval.ProcessWorkitemRequest();
approvalProcess.setComments(comment);
approvalProcess.setAction(isReject ? 'Reject' : 'Approve');
approvalProcess.setWorkitemId(recordId);
approvalProcess.setNextApproverIds(new String[] { nextApproverUserId });
return Approval.process(approvalProcess)

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .