cancel
Showing results for 
Search instead for 
Did you mean: 

process variable with Javascript API

sos81
Champ in-the-making
Champ in-the-making
Can I set a value to a process variable using javascript API ?
1 REPLY 1

steven_okennedy
Star Contributor
Star Contributor
Yes,

Which Javascript API are you talking about?  E.g. are you running your Javascript within an Activiti ExecutionListener or TaskListener or are you doing something from within Alfresco which you want to affect an already running workflow?  For the former, you full access to task and execution level variables as appropriate depending on what point in the workflow you're running the script code

var first = execution.getVariable("myVar1")
var second = "test123"
execution.setVariable("myVar2", second)


For the latter, you can use the workflows root scoped object to get you access to the section of the Workflow Services that Alfresco exposes to Javascript: http://docs.alfresco.com/5.1/references/API-JS-WorkflowService.html.  With that you can gain access to specific processes, tasks, workflow transitions etc and tirgger the workflow from outside Activiti code

Regards

Steven