03-13-2018 06:22 PM
Hi all,
I want to add some custom properties to workflow instances of a custom activiti wf. These custom properties shoud be used by task queries in custom web scripts.
Question 1: how to add properties to workflow instances ? (not to tasks) Using wf start task ?
Question 2: where to find example on how to use setProcessCustomProps method of WorkflowTaskQuery class ?
Thanks,
Vincent
03-16-2018 08:56 AM
1) Yes, using the workflow start task would be the default way of adding these properties to the process instances. At runtime (inside an Activiti task / execution listener) you can also use the execution object to set variables - be aware though that there is a multi-level, inheritance-based isolation model for variables and as soon as a variable is set i.e. within the context of a process branch, it will be hard(er) to update the same-name variable on the global process instance scope.
2) What kind of example do you need? It is a simple setter which takes a map of properties, so any example should be as simple as:
Map<QName, Serializable> processProps = new HashMap<>();
processProps.put(WorkflowModel.PROP_SEND_EMAIL_NOTIFICATIONS, Boolean.TRUE);
// ...
taskQuery.setProcessCustomProps(processProps);
03-16-2018 11:27 AM
Thanks for your response.
Maybe I misunderstood something, but I can't find any way to read properties from a workflow instance in JAVA.
When adding custom properties at workflow startup using workflow start task, how to read these properties afterwards ? I can of course get the start task from workflow instance and read its properties like below, but I'm not sure it's the proper way to proceed....
<code>
WorkflowTask startTask = workflowService.getStartTask(workflowInstance.getId());
Map<QName, Serializable> processProps = startTask.getProperties()
.....
<code/>
ps: stupid question: I can't find how to format code properly in this forum ?
Explore our Alfresco products with the links below. Use labels to filter content by product module.