cancel
Showing results for 
Search instead for 
Did you mean: 

5.22 get process instance creater in script task

long241191
Champ in-the-making
Champ in-the-making

Hi all.

I'm using activiti v5.22, and in script task i want assign creater username into my string.

I found one solution is use ${initiator}, but i can use in script task content;

ex: var message = "Hello " + ${initiator}.

How can I do this? 

Many thanks.

3 REPLIES 3

daisuke-yoshimo
Star Collaborator
Star Collaborator
var message = "Hello " + execution.getVariable("initiator");

Activiti User Guide 8.5.2. Script Task 

long241191
Champ in-the-making
Champ in-the-making

I have try, no error when execute, but result is NULL

message = "Helllo null";

daisuke-yoshimo
Star Collaborator
Star Collaborator

If you set the initiator setting as the start event, you can get it.

initiator: identifies the variable name in which the authenticated user id will be stored when the process is started. Example:

Activiti User Guide 8.2.6. Start Events 

1. initiator setting in bpmn

<startEvent id="request" activiti:initiator="initiator" />

2. If you set the above, you can get it with the following script.

var message = "Hello " + execution.getVariable("initiator");