Serious issue with workflows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashballan
    Member
    • Apr 2018
    • 66

    Serious issue with workflows

    This was driving me mad until I figured out what was going on.

    I have an entity Event with a workflow that has Tasks auto-created for it when a new Event is created. Simple.

    Now, I have another entity called SUB that is linked to Event in one-to-many relation. When a new SUB is saved there is a workflow that "Update Related Record ยป Event", the parent Event. However, when the related Event record is updated using that SUB workflow the workflow that creates the Tasks when a new Event is created is triggered and new Tasks are created AGAIN! So now whenever a SUB is created new Tasks are created for the parent Event although these tasks should be created only once when a new Event is created!

    Is this a bug? How should I tackle this? I need these workflows to work properly please!
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Could you attach screenshots with your workflows?

    Comment

    • ashballan
      Member
      • Apr 2018
      • 66

      #3
      Attached..

      The BEO is the SUB I mentioned above. So when the BEO workflow is triggered and it updates the related Event record the "Event: Follow-up reminder" is triggered but it shouldn't.
      The code in the "Event: Follow-up reminder" workflow is this in case you need it:
      parentType = "Event";
      parentId = eventId;
      parentName = event.name;
      ifThenElse(event.assignedTo != "",
      name = string\concatenate("Event follow-up [", event.assignedTo, "]: ", event.name),
      name = string\concatenate("Event follow-up: ", event.name)
      );

      I had to disable the BEO workflow to avoid the issue.. when it's enabled Tasks are created when they shouldn't.

      Thanks..
      Attached Files
      Last edited by ashballan; 05-18-2018, 03:28 PM.

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        I need some time for reproducing and digging, but

        Comment

        • yuri
          Member
          • Mar 2014
          • 8440

          #5
          Hi,

          As a workaround you can add the formula condition to the first workflow:
          Click image for larger version  Name:	f.png Views:	1 Size:	5.7 KB ID:	38022

          I will look into.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • ashballan
            Member
            • Apr 2018
            • 66

            #6
            That is an awesome suggestion!! Thank you, worked perfect! And thank you for looking into this issue.

            Comment

            • ashballan
              Member
              • Apr 2018
              • 66

              #7
              I faced another issue related to the above, see attached please. I added a simple workflow "Event_StatusChange.jpg". It just checks if the Status of the main Event has changed and if it did it changes the Status of the related BEO entities to the same Status. I have no other workflows that trigger on Status. But when this workflow triggers it goes on endlessly until the system times-out. See "Event_StatusChange_log.jpg", hundreds of logs are created where the system is endlessly triggering this event. The Status of the BEO related records is changed correctly to match the main Event but why is this workflow triggered endlessly?

              Please help..
              Attached Files

              Comment

              • yuri
                Member
                • Mar 2014
                • 8440

                #8
                It's a loop caused by two workflows invoking each other.
                If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                Comment

                • ashballan
                  Member
                  • Apr 2018
                  • 66

                  #9
                  But I don't have two workflows invoking each other.

                  Comment

                  • yuri
                    Member
                    • Mar 2014
                    • 8440

                    #10
                    1. Update Event if BEO changed.
                    2. Update BEO if Event changed.
                    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                    Comment

                    • ashballan
                      Member
                      • Apr 2018
                      • 66

                      #11
                      Yes, but shouldn't the condition of the Status must have changed stop the looping? There are conditions that should break the cycle, no?

                      Comment

                      • ashballan
                        Member
                        • Apr 2018
                        • 66

                        #12
                        I was able to solve this by using a Formula for a condition: !entity\isNew() && datetime\diff(dateStart, event.dateStart, 'days') < 0

                        For some reason the UI condition wasn't evaluating correctly, see attached, and the workflow was being triggered regardless. If you notice the Formula and UI condition are the same but I had to add the Formula to avoid the workflow triggering although the UI condition is not true.

                        Is it my logic or a hidden bug?
                        Attached Files

                        Comment

                        • tanya
                          Senior Member
                          • Jun 2014
                          • 4308

                          #13
                          It's not a bug. You have to find a way, how to catch looping. If your way is good for you, you can skip mine.

                          You can create notStorable boolean field with default true value; (let's name it flag)
                          If you update this record with workflow, set the value in false.
                          Add in condition add if flag is true

                          Comment

                          Working...