I have created a number field in the contact object and created a trigger which is adding one number to the number field, a workflow doing the same, and a process builder doing the same now I have added 1 in the number field and hit save and the number field value updated to 6 because before trigger made it to 2 then workflow made it 3 then trigger again made it 4 and then process builder made it to 5 and again trigger updated it to 6 but now when I deactivated workflow I got 4 and also 4 when I deactivated process builder but when I deactivated trigger then I got 2 as the final output but it should be 3 because workflow will make it to 2 then process builder should make it to 3 but it didn't happen like this it updated the number field to just 2 could someone please make me understand how I got only 2 not 3

and one more question related to recursive save:

public class ContactTriggerHelper {

    public static boolean beingupdated = true;

    public static void validationTesting(List<Contact> Contacts) {
        if(beingupdated) {

// some logic and here

            beingupdated = false;
            update contactRecord;
            // if I write beingupdated = false; here then it will be stuck in recursion

now if I write beingupdated = false; just before the update DML then it wont fall into the recursion but when I write it just below the DML then it will be recursion. can someone please be kind to help me with these 2 scenarios?

  • 1
    It's very hard to follow your description of the issue. This sounds like an exercise in trying to understand the order of execution between triggers, workflows, and process builder. Correct? Are you trying to solve an actual problem or just trying to understand the interaction between these three things? – Chris Johnson Sep 17 '19 at 15:20
  • I am preparing for my PD 2 credentials so it just an exercise to understand the things in a better way – gs650x Sep 17 '19 at 15:57

The second piece of your question is an example of a (usually) non-pathological recursion guard, where you suppress recursive trigger operation only around a single DML operation. You'd usually have it like this:

    if (!beingupdated) {
        beingupdated = true;
        update contactRecord;
        beingupdated = false;

This ensures that your code doesn't recurse solely during that DML operation. It's important to always reset that static Boolean guard after the DML operation, so that the trigger will operate correctly for the rest of the transaction.

Your description of your Process Builder/Workflow Rule/Trigger setup is hard to follow. To get a clear answer, it would be necessary to show the actual setup for the case you are interested in, not the other results you observed.

  • Thank you David for your response, I have created 1 process builder and a workflow rule which increments the value of a number field by 1 now as per the order of execution workflow rule will fire first and it will increment the number field to 1 if I have entered one it will make it to 2 and process builder will run then will it get the original value one or the updated value from workflow which is 2 – gs650x Sep 17 '19 at 18:07
  • @gs650x Please edit your question. Including clear screenshots of the automation may help, and if you can try to write simple, clear sentences it'll help folks follow. – David Reed Sep 17 '19 at 18:07

i was with @gs650x while we are working on above. And yes this is related to Order Of execution.What we are doing here is we have created a field in contact object named 'NumberField' of datatype 'number' as shown below

Number Field On Contact

What logic we are using here to test order of Execution is we have created 1) A trigger to add Integer 1 to Number field 2) A Workflow to perform same task & 3) A Process Builder to do same add Integer 1 to Numberfield field of Contact object

Trigger :

enter image description here

Process Builder

enter image description here


enter image description here

What we did is first we have activated all 3(Workflow, Trigger & Process Builder) & we have given NumberField =1 (manually Updated) after hitting save Button it is 6 as shown in image 1 because we believe , first before trigger runs it add 1 to NumberField .Now NumberField=2 , then Workflow runs it add 1 to it & again trigger Runs (as per Order of Execution) & Numberfield =4 which is now Input to Process Builder & it becomes 5 after Process Builder got executed.After that again trigger runs & its finally 6 & All Processes are terminated . See Logs below

enter image description here

EXPECTED RESULT:-Now we have deactivated Workflow.. and Trigger & Process Builder have been executed.(Trigger Twice & PB Once) which made NumberField=4 AS shown below


Not to make Lengthy we got same result when only Process Builder was deactivated


Now Trigger was deactive & we are running Workflow & Process Builder . When we edit NumberField & save it to 1 , we expect first Workflow will run which makes it 2 & then PB will run which will make it to 3 . But we are not getting the same

  • You didn't show the definition of the workflow rule... but in my testing I found that I can recreate your issue (the Not Expected) portion of your update if I set the workflow to "created, and any time it's edited to subsequently meet criteria." If I set the workflow to "created, and every time it's edited," the combination of the Workflow Rule and Process Builder increment the number to 3 (as expected). Could you please confirm the settings on your workflow? – Chris Johnson Sep 18 '19 at 12:50
  • To add a bit more detail... if you have the workflow set to "created, and any time it's edited to subsequently meet criteria," it would not fire again unless something changed to make the workflow reevaluate the criteria. If your formula on the workflow is something like "true" -- it will never reevaluate. – Chris Johnson Sep 18 '19 at 12:52
  • Thank you very much @Chris..it worked – Swarandeep Singh Sep 19 '19 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.