Still getting some issues when trying to set process custom properties and get it using worklflow service API.
Following axel recommendations, I did the following:
1) create aspect with optionnal properties and add it as mandatory aspect to process start task model
2) set these properties in ScriptTask / Scriptexecution listeners.
Result observed:
I defined two process listeners (org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener): one on 'start' event, one on 'end' event.
When setting the custom property by script on start event execution listener, property is set and accessible using workflow service. When setting the property on 'end' event (or from any other ScriptExecutionListener/ScriptTaskListener), the property is not set (or not visilble from workflow service).
Any idea ?
Thanks,
Vincent
Just to complete this topic: as Axel explained above, any process property can be set from task/process activiti listener and read by workflow service as soon as the property is defined as a process (start task) property.
Listener code:
DelegateExecution execution = task.getExecution();
ProcessInstance processInstance = execution.getEngineServices().getRuntimeService().createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId()).singleResult();
execution.getEngineServices().getRuntimeService().setVariable(processInstance.getId(), "myPrefix_myProcessVariable", "myValue");
Wf model
...
<!-- Submit process task -->
<type name="myPrefix:submitTask">
<parent>bpm:startTask</parent>
<mandatory-aspects>
<aspect>myPrefix:myAspect</aspect>
</mandatory-aspects>
</type>
.....
<aspect name="myPrefix:myAspect">
<properties>
<property name="myPrefix:myProcessVariable">
<type>d:text</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>false</tokenised>
<facetable>true</facetable>
</index>
</property>
</properties>
</aspect>
....
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.