Issue with Handling Local Variables in Subprocess

Hello everyone,

I am encountering a problem in a BPMN process I have configured and hope someone can help me. The main process includes a subprocess responsible for invoice management, covering tasks such as logging, reviewing, and approval. Within the subprocess, a human task reviews the invoices and classifies them as approved or rejected.

After classification, a script task separates the correct and rejected invoices into two local variables (gridFacturasIncorrectas and gridFacturasCorrectas). Then, an inclusive gateway checks for elements in each group and directs the flow accordingly.

The issue arises when there are both approved and rejected invoices. In this case, the flow for approved invoices generates an error in the “Resultado Variables” task with the following message:

ENGINE-16004 Exception while closing command context: Unknown property used in expression: ${gridFacturasAprobadasParcial}. Cause: Cannot resolve identifier ‘gridFacturasAprobadasParcial’

Interestingly, when all invoices are approved and none are rejected, the flow runs smoothly, and the gridFacturasAprobadasParcial variable is accessible at any point in the subprocess.

Has anyone faced a similar issue or can provide insights on how to resolve this?

Hello my friend!

From what I saw in the image, this subprocess of yours appears to be a multi-instance.
Is its execution sequential or parallel?

If it is parallel… you need to make sure that the variable in question is not being shared between instances of the same multi-instance.

Imagine that a variable can be updated by an instance, and then another instance updates the same variable, which could result in inconsistent data, or even optimistic locking errors.

William Robert Alves

Hello William,

Thank you for your response.

The subprocess is indeed parallel, but the variables for each instance of the subprocess are being created locally to avoid the behavior you mentioned, ensuring that each variable has its own value and does not affect the other instances of the subprocess when they are using said variable.

In the subprocess task, there is a list of data—in this case, invoices—which are verified, and a value is added to each invoice to determine if it is correct or incorrect. Subsequently, the script task retrieves the list and classifies which invoices are correct and incorrect, creating two new variables that are lists. Then, in each sequence flow, it is validated if the number of items in the list is greater than 0, the flow continues; otherwise, it does not.

When there are no incorrect invoices, the incorrect flow is not activated, and the subprocess works correctly without generating the error “Unknown property used in expression: ${gridFacturasAprobadasParcial}.” However, if the incorrect flow is activated and both flows are active, this is when the error occurs. I am not sure if it is because the incorrect flow returns to previous tasks and this affects the tasks in the correct flow.

Thank you!

Hello @Carlos_Humberto_Cace

Can you reproduce this problem or does it only happen under certain circumstances (fx heavy load)?

I have tried to create a simple example of what I think your process does, and I have not been able to re-create the problem you describe.

Here is what I have done. Let me know, if I am missing something compared to what your process does.

I have created the following process:

The activity “Create Order List” creates a list with a number of Order objects, each order has a list of Invoice objects. Each invoice has a simple boolean to mark it as approved or not (rejected).
This order list is set as a global process variable.

The multi instance sub process iterates over this order variable using a process variable called “Order” for each instance.

Multiple sub processes are then started and each sub process runs the activity “Sort Invoices” which takes the invoices from the order and sorts them. The approves invoices go into an approved list and the rejected go into a rejected list. Each of these lists are then set as local process variables.

When running this with 2 orders with each order having 2 invoices - 1 approved and 1 rejected.
Everything looks correct inside that Cockpit.
The Orders process variable is of global scope and the single Order process variables and the 2 lists are of local scoped for each instance of the multi instance sub process activity.

Are you doing something else that I am not in this simple example?

BR
Michael

Hello @mimaom
The issue we encountered was due to the scope of the variables; they were defined locally rather than globally, which caused the error. Thank you very much for your support!