setProcessCustomProps task query: how to use

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

setProcessCustomProps task query: how to use

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

2 Replies
afaust
Master

Re: setProcessCustomProps task query: how to use

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);
Highlighted
vincent-kali
Established Member

Re: setProcessCustomProps task query: how to use

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 ?