Embedded process engine, getting Unknown property used in expression

Hello Everyone, new user here trying to get up to speed on using the process engine within a java application. I have a simple model with a couple of user tasks. I am able to create an instance of the model programmatically with
ProcessInstance pInstance = runtime.createProcessInstanceByKey(“pto-request”)
However when I try to complete the first user task, I receive an Exception while closing command context: Unknown property used in expression: ${ptoStatus == ‘accepted’}. Cause: Cannot resolve identifier ‘ptoStatus’. This process variable is defined as a conditional expression later in the flow – unreachable from the first user task.

I was able to deploy this model to the BPMN Run container, and then use Cockpit and Task List to create an instance of the process and complete the first user task without defining the “ptoStatus” variable, The goal is to create that variable when the second user task is completed. Here is the code being used to complete the first user task
Task specifyHoursTask = tasks.createTaskQuery()
tasks.setVariable(specifyHoursTask.getId(), “ptoHours”, 4);

Any suggestions would be greatly appreciated, thank you in advance.

pto-request.bpmn (6.6 KB)
This is the complete model. Using Camunda version 7.15

@atitus Sequence flows are not connected properly from these tasks Specify Hours > Approve or reject > Exclusive Gateway


It should be like below::



Wow, nice catch @aravindhrs, the way the model looked I didn’t even think to check for that. Quick follow up question if I may. I noticed you checked the Async before option. Just so that I understand for this model and for the future – is that always needed? It was my understanding that user tasks always result in the save point.

@atitus Yes. You’re correct. User Tasks by default has its save points. You can ignore them.

We need save points only if the activity type doesn’t have savepoint and we try to access a variable which was set in that activity.

To confirm, just i tested this process without savepoint and it worked!!!

pto-request.bpmn (6.8 KB)

1 Like