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
AleksAAleksA 

Process builder firing Apex class multiple times

Hello,

We have a Process Builder process on the Account object. The Action Group Criteria has Is changed for about a dozen different fields. If any of the conditions are met it calls a custom Apex class that makes a HTTP POST to our API endpoint. This works fine if users are manually changing these fields. 

We also have a different, existing process, that updates the Account whenever an Opportunity is Close Won. Most of these fields also appear on the Opportunity.

What we expected is for it to send a single POST if any of these conditions are met. What we get is that it sends 6 POSTs whenver the Opportunity is closed and the Account is updated.

Recursion - Allow process to evaluate a record multiple times in a single save operation? is not checked

What can we do to make it fire only once if any of the conditions are met?

Thank you for the help!
Hayat Ansari 7Hayat Ansari 7
Hi,

Please make sure the below checkbox on the criteria group is selected,

"Do you want to execute the actions only when specified changes are made to the record?" for more details please refer imageAvoid recursion

Let me know if it works.
 
Maharajan CMaharajan C
Hi,

Try with help of boolean to stop this recurrsion. Please refere the below blogs.

https://help.salesforce.com/articleView?id=000324749&type=1&mode=1
https://www.sfdcpoint.com/salesforce/avoid-recursive-trigger-salesforce/
https://salesforce.stackexchange.com/questions/101812/trigger-is-firing-twice-after-update
https://www.biswajeetsamal.com/blog/avoid-recursive-trigger-calls-in-salesforce/#:~:text=Recursion%20occurs%20when%20same%20code,%E2%80%9Cmaximum%20trigger%20depth%20exceeded%E2%80%9D.

Thanks,
Maharajan.C
AleksAAleksA
Thanks for the response!

Unfortunately cannot use that checkbox as I am using Is changed criteria so will get: The Is Changed operator can't be used if you choose the advanced option to execute actions only when specified changes are made to the record. Please change your criteria and try again.

I will look into using boolean flags.