Unknown property used in expression after deleting process instance

Hi guys. I’m looking for solution of my problem. In my process I define and set process instance variable in one of service tasks the middle of the process. And this process instance variable is then used in output mapping of Call activity in parent process which invokes the process instance. The query used in output mapping is ${MA_RESULT_CODE.toString()}.

It works under standard contitions but I have problem in scenario when the process instance is deleted (i mean deleted using org.camunda.bpm.engine.RuntimeService#deleteProcessInstance(java.lang.String, java.lang.String, boolean, boolean) - the process instance which is killed by this method is root process of the “call activity stack”) before the variable is set. In such case it looks like the engine tries to invoke output mapping expression and it fails with

"ENGINE-16004 Exception while closing command context: Unknown property used in expression: ${MA_RESULT_CODE.toString()}. Cause: Cannot resolve identifier 'MA_RESULT_CODE'" exception.

That’s not a surprise because the MA_RESULT_CODE variable hadn’t been set before the instance was deleted.

My questions are:

  1. is it ok than the engine applies the output mapping in such case?
  2. can I somehow avoid it?
  3. is there any “best practice” for using the process variables in a way I described (variable set somewhere in the middle of the proces + output mapping using the veriable in the expression)
  4. do you have any proposal how I can solve this issue? I have some ideas but I don’t want to bias you :slight_smile:

I’ve same issue :frowning: what was your solution?

My be this will solve your problem:

https://jira.camunda.com/browse/CAM-6749

and the exact method to call will be:

https://docs.camunda.org/javadoc/camunda-bpm-platform/7.9/org/camunda/bpm/engine/RuntimeService.html#deleteProcessInstance(java.lang.String,%20java.lang.String,%20boolean,%20boolean,%20boolean)

where default values are:

boolean skipCustomListeners = false
boolean externallyTerminated = false
boolean skipIoMappings = false

where probably changing last one to:

boolean skipIoMappings = true

should solve your problem.

1 Like