Announcement

Collapse
No announcement yet.

When a call to a subprocess is fully finished?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • When a call to a subprocess is fully finished?

    Hello.

    We have an e-commerce (WooCommerce) that we have connected with espoCRM.

    Every time a sale is generated in WooCommerce a mirror record is generated in espoCRM. A sale generates in espoCRM a WCOrder record and n WCOrderLine records related to it

    This part of the integration between WooCommerce and espoCRM works well.

    Within espoCRM we have prepared the process so that once a WCOrder record has been created it will generate a logistic order.

    There is a BPM process that for each WCOrder created, a LGOrder record and its n LGOrderLine are generated.

    In the image you can see what happens when that BPM is executed:

    1.- The sub-process finish with Status"Rejected". However, if I consult the detail of the sub-process, I see that all its steps have been executed correctly.

    2.- The process stops at the script task "CT 1" step (Final calculation). Its status is "Created", and is marked in blue in the image.

    I have already discovered what generates these two effects: it is the code included in the "CT 1" step.

    There is an entity\countRelated instruction on the records that have been generated within the sub-process, the n LGOrderLine. These are the instructions:

    ifThenElse(
    entity\countRelated('lGOrderLines', 'reportFilter5e4d1d30c2c8of32f') > 0,
    $prLGLineBusinessGXC = 1,
    $prLGLineBusinessGXC = 0);

    If I delete that code, the sub-process is processed correctly (it does not have a status "Rejected" any longer) and the process continues to its end without stopping.

    I understand that when the main process relinquishes control to the sub-process, the main process is stopped until the sub-process ends.

    Then the sub-process returns control of the flow, including the return variables.

    Therefore the subprocess should be completely finished.

    But the reality is that it does not allow the entity\countRelated code to be executed. So it doesn't seem that the subprocess is completely finished.

    I don't know if what I described is a mistake or it is the behaviour that was intended.


    Anyway , how can I solve this situation? How can I count those records?

    Thank you very much for your help.


    Attached Files

  • #2
    Hi,

    Sorry. But I don't understand the main question. I'm confused.

    https://github.com/espocrm/documenta...tycountrelated

    The first argument is LINK. Link name can't start with upper case character. Try to specify the proper link name: https://github.com/espocrm/documenta...naming.md#link

    Last edited by yuri; 04-22-2020, 06:30 AM.

    Comment


    • #3
      Hi yurikuzn

      No. The issue is not a problem or correct coding. I had used the same exact code in a diffferent context and worked perfectly.

      The first letter is an "L" in lower caps. That looks like the vowel "I" in caps. But I have followed the namen criteria.


      Once discarded that about the proper code of entity\countRelated , the issue is:

      There is a FIRST entity has a relation 1:n with SECOND entity.

      There is a main BPM Flow.
      In that Flow I create a record in entity FIRST.
      Then I call a subprocess that creates several records in entity SECOND
      Once the flow has returned to the main Flow I execute a entity\countRelated on the records already created in entity SECOND

      And there is when the BPM fails:
      1.- It says the Subprocess execution was rejected. In fact, it was fully executed.
      2.- Stops at the task with entity\countRelated code.

      If its still not clear I can create an example with it in demo

      Thanks in advance

      Comment


      • #4
        How I see what's going on.

        The error occurred in the element after the sub-process element. By the time error is occurred, the sub-process node is not yet marked as complete, it's about to. When the process is terminated, it sets all not finished flow nodes as Rejected.

        I will investigate why it's not marked as complete. But first I need to reproduce somehow.
        Last edited by yuri; 04-22-2020, 12:17 PM.

        Comment


        • #5
          Are you sure that sub-process node has status Rejected but not Failed?

          Comment


          • #6
            Sorry. My computer crashed and couldn´t answer earlier.

            You can see in the attached images that

            1.- the main process continued after the failure of the subprocess. It failed ("Ha fallado" in spanish) in step 7 but step 8 was executed and tried step 9. Step 9 was in status Created but I changed it by hand to rejected ("Rechazado" in spanish)

            2.- The subprocess is marked as failed, but in its log can be seen everything was processed from A to Z

            I´ll try to define something simple in your demo web later this evening for you to review. Need to go to a videoconf right now
            Attached Files

            Comment


            • #7
              'Failed' and 'Rejected' are different statues. I've been in wrong direction for some time.

              To fix this behavior.

              File application/Espo/Modules/Advanced/Core/Bpmn/Elements/TaskScript.php

              Find try catch block and change catch line to

              PHP Code:
              } catch (\Throwable $e) { 

              This will not prevent the process from failing. It will fail because the error occurs in the script. This will just won't mark previous sub process as failed.

              Comment


              • #8
                Sorry for this. 'Failed' and 'Rejected' are different statues. I've been in wrong direction for some time. I know are different but I wrote it wrong.

                Comment

                Working...
                X