You need to sign in to do that
Don't have an account?
RadDude89
Apex trigger to automatically invoke approval process
Hi,
I have created an approval process for a custom object called Offer which is based on several selections regarding the creation of the offer.
The offer is to be locked and sent to a manager for approval when the criteria is
Price <0.200 and Region= NI
What I have realised is that when the offer is created the approval won't start - the user has to press the Submit for Approval for it to start.
Is it possible to create a trigger to kick the approval process off automatically when the offer has been created?
You can write trigger as follow,replace with API names as you have. Best Regards,
Amit Ghadage.
All Answers
You can write trigger as follow,replace with API names as you have. Best Regards,
Amit Ghadage.
1) http://www.jitendrazaa.com/blog/salesforce/dynamic-approval-process-based-on-the-apex-and-trigger/
Let us know if this will help you
Hi,
Thanks for the replies - I've tried using the approval process submitted from Amlt Ghadage but when I compile it, I get the error
Variable does not exist: req at line 7 column 13
How should I declare that variable?
Create a approval proccess on the offer object and put one of the entry criteria as Price < 0.200
Now to trigger the approval process you can use process builder rather than trigger which will save you from writing code.
And if still you want to use trigger check the price in trigger and add the following line of code
1) http://www.jitendrazaa.com/blog/salesforce/dynamic-approval-process-based-on-the-apex-and-trigger/
Full detail and sample code is given in above link
Let us know if this will help you
Thanks for your help guys I got this working.
But I have another question - is it possible to use a trigger to invoke an already created approval proccess.
So for example - I have created an approval process with various email alerts, field updates (based on approval and rejection).
Can a trigger be developed to call a particular approval process?
So I have an approval process with the Salesforce ID of '04a8E000000DfNn', can you use the code above to call that ID and start the approval once the record has been created?