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
CaroRCaroR 

Question: Trigger on Approved record in approval process

Hi,

 

Is it possible to have a trigger only fire on a record that is approved at the end of an approval process?

 

I have an after update trigger that does some cascading updates on associated child records. Now we want to introduce an approval process and only have the child updates happen on final approval of the change.

 

As I have not worked with approval processes before any help will be much appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
crmexpertcrmexpert

Hi,

 

Have worked on something like this before. the case was, there was an approval process set for 'rate card' to be approved by a sales manager so that if he approves the same, a pricebook with all the entries of the rate card will be created. 

 

see the process would something be as follows:

1. create a custom field on that object. name the field as 'isApproved'

2. create an approval process, and in that a 'field update' workflow such that whenever the process gets approved the workflow makes the 'isApproved' field 'true'.

3.so now, the field is updated..that means the record is updated.

4. create an 'after update' trigger for the record and make sure the trigger fires when:

         a) when the 'isApprove' is true

         b) after update 

5. now the trigger would be fired and hopefully your functionality would be achieved.

All Answers

crmexpertcrmexpert

Hi,

 

Have worked on something like this before. the case was, there was an approval process set for 'rate card' to be approved by a sales manager so that if he approves the same, a pricebook with all the entries of the rate card will be created. 

 

see the process would something be as follows:

1. create a custom field on that object. name the field as 'isApproved'

2. create an approval process, and in that a 'field update' workflow such that whenever the process gets approved the workflow makes the 'isApproved' field 'true'.

3.so now, the field is updated..that means the record is updated.

4. create an 'after update' trigger for the record and make sure the trigger fires when:

         a) when the 'isApprove' is true

         b) after update 

5. now the trigger would be fired and hopefully your functionality would be achieved.

This was selected as the best answer
Guyver118Guyver118
as soon as isApproved is true the trigger will keep firing so better have some sort of finished flag.