Using ProcessInstance Title as a variable

Hello,

I’m trying to use the Process Instance name as a variable, to show it in the body of a MailTask.
However, I’m having difficulties doing so. I can’t seem to find it mapped to any variable.
I dug around the code for a bit, and it seems that in VariableContainerELResolver the only variables that are mapped are the ones set during process execution and the “initiator”, which leads me to believe maybe this isn’t mapped.

As a workaround, I tried using a Script Task to set the Process Instance’s name using the following Script:

String title = execution.getName();
execution.setVariable("title", title);

This sets the variable title, but maps it to null. I assume getProcessInstanceName() does not return what I expect it to.
I know Execution has a getProcessInstanceId(), how can I get the Instance name from the given Id?

Thanks

Hi @JoaoPPinto

Have you tried:

${execution.getParent().getName()}

or

${execution.getProcessInstance().getName()}

?

Hi @JoaoPPinto

I know you said that you want to get process instance name, but there should be also process definition name so it might be useful:

${execution.getParent().getProcessDefinitionName()}

${execution.getProcessInstance().getProcessDefinitionName()}

Hi @JoaoPPinto

Also bear in mind that if you start process without passing process instance name you will get null/empty value.
Look at those classes:

and ProcessInstanceBuilderImpl class