BPM: Problems with "Conditional Intermediate Event (Boundary)" on multi-instance task

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hi-ko
    Member
    • May 2015
    • 97

    BPM: Problems with "Conditional Intermediate Event (Boundary)" on multi-instance task

    I have a Problem with Advance Pack 3.7.2 / EspoCRM 9.0.4 using a "Conditional Intermediate Event (Boundary)" event on a multi-instance sub-process:

    Click image for larger version

Name:	grafik.png
Views:	91
Size:	72.7 KB
ID:	115683

    My goal is to stop the multi-instance sup-process for review if a user selects in the review task "changes" as resolution.
    In the sub-process a script task checks the user task's outcome and once the "resolution" is "changes" the entity property "status" is set to "changes"
    I created ​a canceling "Conditional Intermediate Event (Boundary)" (Changes) which has the condition "status"="changes".

    Once this event fires I have 2 issues:
    * the event is not only cancelling the sub-process but also the main process. Then in a later "Send Message Task" fails with status 500 because the process already ended:
    [2025-03-06 12:02:46] ERROR: (500) Attempted to continue flow of not active process 67c98ec68d02ef31e. :: /var/www/html/espocrm/custom/Espo/Modules/Advanced/Core/Bpmn/BpmnManager.php(892)
    * If the "Conditional Intermediate Event (Boundary)" (Changes) fires, the multi-instance subprocess does not write the "Collection Return Variable", so I have no way to read the outcome in the main process. I tried to add a inclusive gateway to wait until the sub-process ended but it looks like the final logic to write the outcome into that collection variable does not run on a boundary event. At least this worked in a previous version.

    Am I doing something wrong or are these bugs in the latest version of the Advance Pack?​

    Thanks for any help
  • yuri
    Member
    • Mar 2014
    • 8778

    #2
    > the event is not only cancelling the sub-process but also the main process. Then in a later "Send Message Task" fails with status 500 because the process already ended

    Did it work before v3.7?

    A minimum reproducible example would be very helpful. From the experience, I can say that it can take hours to reproduce without having a concrete min example.
    Last edited by yuri; 03-06-2025, 12:56 PM.
    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

    • yuri
      Member
      • Mar 2014
      • 8778

      #3
      > the multi-instance subprocess does not write the "Collection Return Variable",

      Do you mean it's not available in the flow outgoing from the boundary event? I believe it never worked that way.
      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

      • yuri
        Member
        • Mar 2014
        • 8778

        #4
        I'm also not sure whether it's correct to use the inclusive gateway. Maybe a parallel gateway is needed instead.
        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


        • yuri
          yuri commented
          Editing a comment
          The converging inclusive gateway requires parallel flows to be active. If there's no two parallel flows in the moment one of the flows arrived to the gateway, it will fail by design.
      • hi-ko
        Member
        • May 2015
        • 97

        #5
        Hey Yuri,
        thanks a lot for your prompt response. I will create and attach a minimal example asap.
        to your questions:
        • The effect that the main process ends too early (probably due to the boundary event) is a new - even with the inclusive gateway. I added the inclusive gateway in the hope that we can wait for the multi-instance sub-flow to complete the variable collection.
        • Do you mean it's not available in the flow outgoing from the boundary event? I believe it never worked that way.
          yes, that's what I mean. In another workflow we had at least access to "return variables" set in the multi-instance sub-flow.
          The use case is to run the review many times in parallel but to stop the sub-flow if any sub-instance chooses "changes" but then we need access to the "changes" details to inform the others. As a work around I could try to write to a variable in the parent process via script but I would prefer to always have access to the instance-collection from the parent process.
        The bug would then still be that the parent process ends as soon as the boundary event fires. The parent process should continue until the end.
        I'll try to isolate/reproduce that issue in a minimal workflow ...​

        Comment

        • yuri
          Member
          • Mar 2014
          • 8778

          #6
          It will be easier if we handle issues separately. Concentrating on a single issue in a moment.

          I'd start with the parent process being stopped.

          Did it start to happen only after upgrade? Did it work before?
          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


          • yuri
            yuri commented
            Editing a comment
            I managed to reproduce the "Attempted to continue flow of not active process" error.
        • yuri
          Member
          • Mar 2014
          • 8778

          #7
          I found the reason. It interrupted the sub-process node before preparing nodes outgoing from a boundary event. From code, it seems as it was done intentionally. I changed the logic (execution order) for all boundary event types. Did some manual testing and run integration tests. Seems works. I'm going to make a release.
          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

          • hi-ko
            Member
            • May 2015
            • 97

            #8
            Hi yuri, thanks a lot for your prompt fix! Now the flow continues as expected.

            Since return variables are not returned to the parent process for an subprocess which is interrupted by an boundary event:
            do you have a tip/advice how to access the outcome of the review task inside the multi-instance sub-process from the main process?

            Comment

            • yuri
              Member
              • Mar 2014
              • 8778

              #9
              Using an entity to store needed data could work.
              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

              • hi-ko
                Member
                • May 2015
                • 97

                #10
                That's what I ended up for now. I write in a hidden entity text field in the sub-flow task and then read that in a later in a script task of the parent flow into variables to have them available in email templates.

                My suggestions for improvement would be:
                • access the variables of a subflow via a script or always expose return variables / return collection variables as a finally method before continuing
                • pass flow's linked entity into the context when executing an email template in an email task (currently I read all required entity data required in the template into flow variables).

                Comment

                • hi-ko
                  Member
                  • May 2015
                  • 97

                  #11
                  Two observations that are at least “unexpected” and could be important to know for others when using multi-instance tasks in bpmn workflows:
                  • When using a "Conditional Intermediate Event (Boundary)" to interrupt a multi instance task (e.g. when first reviewer denies), the multi instance subflow will not write the return/return collection variables to the parent flow and therefore any following tasks will not have access to the subflow's outcome. As a work around the outcome like the tasks resoluiton or resolutionNote should be written additional to a custom field in the related entity by a script task in the multi instance subflow.
                  • The "Conditional Intermediate Event (Boundary)" does not fire, if the current task is the last of the sublfow's inputCollection. As a work around one would need a exclusive gateway in a later step to check the custom fields written by script before.
                  I would consider at least the second point to be a bug.​ The first point should be addressed by always writing the return/return summary variables - regardless of whether the sub-process has ended by completing all parallel tasks or has been stopped by a boundary event.​

                  Comment

                  • yuri
                    Member
                    • Mar 2014
                    • 8778

                    #12
                    Return data not being passed to the boundary flow is not related to the fact that the sub-process is multi-instance. It's not passed by design. We can call it the limitation of the implementation. It can be worked around currently. Unfortunately, we cannot address this problem soon, as it's not a bug.

                    > The "Conditional Intermediate Event (Boundary)" does not fire, if the current task is the last of the sublfow's inputCollection. As a work around one would need a exclusive gateway in a later step to check the custom fields written by script before.

                    I'm not sure I understand. If I understand right. The boundary conditional event is not synced with flow execution. It is checked in-idle. It's how it was designed, not a bug. We can call it the limitation of the implementation.
                    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


                    • yuri
                      yuri commented
                      Editing a comment
                      Added to docs about in-idle checking.

                      The limitation with boundary event not being in sync was dictated by performance trade-offs.

                      Regarding not returning collection through a boundary event. My option that it would be not a good design choice to do so as it introduces edge cases. E.g. not all sub-processes instances has been started, or some sub-process instances have already prepared needed data, some -- not.
                  • hi-ko
                    Member
                    • May 2015
                    • 97

                    #13
                    The boundary conditional event is not synced with flow execution. It is checked in-idle.
                    OK, that explains the behavior. The boundary conditional event is checked async and therefore the last task may complete the sub-process earlier and then the boundary conditional event will never fire.

                    Comment

                    Working...