cancel
Showing results for 
Search instead for 
Did you mean: 

Passing variabl to a shell task

dmill
Champ in-the-making
Champ in-the-making
Hello guy,

I'm using Activiti-rest and having a hard time figuring out how to use variables in a shell task.

I create a process instance using POST runtime/process-instances:
{
   'processDefinitionId':'xxxxx',
   'variables' : [
     {'name' : 'myVar', 'value' : 'something'}
   ]
}

And my process definition contains:


<serviceTask id="console" activiti:type="shell" >
   <extensionElements>
      <activiti:field name="command" stringValue="echo" />
      <activiti:field name="arg1" stringValue="${scriptVar}" /> 
   </extensionElements>
</serviceTask>

But this doesn't work. The process runs properly otherwise.

Any help would be appreciated.
12 REPLIES 12

dmill
Champ in-the-making
Champ in-the-making
Thanks for the reply martin but this doesn't seem to work. If you check my example from post #5 you will see that this is not producing the expected result.
The variable is correctly set when I check activiti-explorer, shows the right characters as well. But acts as if it's null when used like you suggest. Which is why I'm confused and seeking help here.

ollib
Champ in-the-making
Champ in-the-making
<code>
<activiti:field name="arg1" stringValue="${myPath}" />
</code>

doesn't work



<code>
<activiti:field name="arg1">
          <activiti:expression>${myPath}</activiti:expression>
</activiti:field>
</code>


does

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,


      HashMap<String, Object> variables = new HashMap<String, Object>();
      variables.put("textToPrint", "Hello World!");
      ProcessInstance pi = runtimeService.startProcessInstanceByKey("echoShellWindowsWithVariable", variables);


  <serviceTask id="shellEcho" activiti:type="shell">
   <extensionElements>
    <activiti:field name="command" stringValue="cmd" />
    <activiti:field name="arg1" stringValue="/c" />
    <activiti:field name="arg2" stringValue="echo" />
    <activiti:field name="arg3" expression="${textToPrint}" />
    <activiti:field name="wait" stringValue="true" />
    <activiti:field name="outputVariable" stringValue="resultVar"/>
   </extensionElements>
  </serviceTask>

Regards
Martin