# Using ProcessInstance Title as a variable

**URL:** <https://forum.flowable.org/t/using-processinstance-title-as-a-variable/3351>\
**Category:** Flowable Engine\
**Created:** [January 30, 2019, 10:38am UTC](https://forum.flowable.org/t/using-processinstance-title-as-a-variable/3351 "2019-01-30T10:38:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoaoPPinto](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@JoaoPPinto](https://forum.flowable.org/u/JoaoPPinto)\
**Post date:** [January 30, 2019, 10:38am UTC](https://forum.flowable.org/t/using-processinstance-title-as-a-variable/3351/1 "2019-01-30T10:38:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rgorzkowski](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/rgorzkowski/32/1365_2.png) [@rgorzkowski](https://forum.flowable.org/u/rgorzkowski)\
**Post date:** [February 12, 2019, 3:31pm UTC](https://forum.flowable.org/t/using-processinstance-title-as-a-variable/3351/2 "2019-02-12T15:31:57Z")

</div>

Hi @JoaoPPinto

Have you tried:

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

or

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

?

---

<div class="post-metadata">

**Author:** ![rgorzkowski](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/rgorzkowski/32/1365_2.png) [@rgorzkowski](https://forum.flowable.org/u/rgorzkowski)\
**Post date:** [February 12, 2019, 3:45pm UTC](https://forum.flowable.org/t/using-processinstance-title-as-a-variable/3351/3 "2019-02-12T15:45:49Z")

</div>

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()}

---

<div class="post-metadata">

**Author:** ![rgorzkowski](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/rgorzkowski/32/1365_2.png) [@rgorzkowski](https://forum.flowable.org/u/rgorzkowski)\
**Post date:** [February 12, 2019, 4:02pm UTC](https://forum.flowable.org/t/using-processinstance-title-as-a-variable/3351/4 "2019-02-12T16:02:15Z")

</div>

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:

> <https://github.com/flowable/flowable-engine/blob/flowable-6.4.1/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessInstanceHelper.java#L176>

> <https://github.com/flowable/flowable-engine/blob/flowable-6.4.1/modules/flowable-engine/src/main/java/org/flowable/engine/impl/RuntimeServiceImpl.java#L712>

and ProcessInstanceBuilderImpl class
