function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
maddukurimaddukuri 

Capturing Approval Steps in the trigger

I have an approval process with multiples steps, say step1 thru step 10. My trigger needs to capture who the approver is at each step and based on the approver perform some functionality. How do I accomplish that in the trigger? Please advise.

Niket SFNiket SF

Hello maddukuri,

 

I think you need to write a trigger on the respective object on which the approval process is working ,

 

 

and then you need to work wih "Approval.ProcessSubmitRequest" Object please check with following sudo code .

 

 

Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setComments('Submitted for approval. Please approve.');
req.setObjectId(Trigger.new[i].Id);
// submit the approval request for processing
Approval.ProcessResult result = Approval.process(req);

 

 

for more information please check with the following link.

http://www.blog.jeffdouglas.com/2010/01/04/automating-salesforce-approval-processes-with-apex-triggers/

 

Thanks 

Nik's

vmadvmad

Thank You Nik! I just want to make sure that I am not trying to rewrite the approval process in the trigger. I need to keep the approval process as it is but in my trigger, based on the approver at each step of the approval process, I need to perform some actions.