Workflow custom props update

cancel
Showing results for 
Search instead for 
Did you mean: 
vincent-kali
Established Member

Re: Workflow custom props update

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

vincent-kali
Established Member

Re: Workflow custom props update

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>

....