I have the following .bpmn2 file deployed through my alfresco workflow console with user task which will be assigned to a user according to the passed variable "Y"
<process isExecutable="true" id="step4reconfigure41" name="Reconfigure step 4">
<startEvent id="start"
activiti:formKey="wf:submitAdhocTask" />
<sequenceFlow id='flow1'
sourceRef='start'
targetRef='adhocTask' />
<userTask id="adhocTask" name="First user Task"
activiti:formKey="wf:adhocTask">
<documentation> First task </documentation>
<extensionElements>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
if(execution.getVariable("Y") == 22){
task.assignee = 'userA';
}
else if(execution.getVariable("Y") != 22){
task.assignee = 'userB';
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
I successfully managed to start the process from the alfresco workflow console like:
- start Y=22
Which was a success as the variable was successfully read and the assignment logic described in the .bpmn2 file was applied accordingly.
I want to perform the same scenario I did using the alfresco rest-api .
According to the api-explorer documentation, I have to use the /processes (POST) endpoint with a processBody like the below one
{ "processDefinitionKey": "string", "variables": { "bpm_assignee": "string", "bpm_sendEMailNotifications": true, "bpm_workflowPriority": 0 } }
I am trying to pass my variable "Y" to the processBody like this:
{ "processDefinitionKey": "test", "variables": { "Y": "5", "bpm_sendEMailNotifications": true, "bpm_workflowPriority": 0 } }
Unfortunately, even the process starts normally, the variable "Y" has not been set, which i tested through the /processes/{processId}/variables endpoint.
What should i do to perform the same action i did on my workflow console (passing the variable on start) through the rest api? And how this variable will be visible in my .bpmn2 file?
Any help would be greatly appreciated :)
Finally I managed to solve this by "expanding" the bpmnModel.xml placed on WEB-INF/lib/alfresco-repository-{version}.jar/alfresco/model/ and added an extra property inside the "bpm:startTask"
<property name="bpm:Y">
<type>d:text</type>
</property>
Restarted server and the new process was successfully created with my new custom parameter passed set by adding to the request
{
"processDefinitionKey": "test",
"variables": {
"bpm_Y": "5",
"bpm_sendEMailNotifications": true,
"bpm_workflowPriority": 0
}
}