cancel
Showing results for 
Search instead for 
Did you mean: 

set owner and involved people in bpmn20.xml

shaparak-smmira
Champ in-the-making
Champ in-the-making

hi to all

i want to set process initiator as task owner in bpmn20.xml ,have any solution for this ?

and i want to set involved people in bpmn20.xml ,have any solution for this ?
8 REPLIES 8

frederikherema1
Star Contributor
Star Contributor
You can use the activiti:initiator="someVariable" (see user guide). Next, you can use a task-listener (event=create) to set the owner, based on the value of "someVariable". Setting involved people can also be done by using a listener (an execution-listener this time). Add an execution-listener on the process (event=start), which implementation involves people with the process. Use field-injection (again, see userguide) to define, for example, a comma-seperated list of users in an <activiti:field …> on that executionListener. This way, the values you fill in in the BPMN can be used by the execution-listener.

zze_one
Champ on-the-rise
Champ on-the-rise
By any chance, is 5.15 providing the following syntax ? 'activiti:involvedUsers="someVariable"'
Or should we still use the task-listener to set involved users and groups.

Thanks

Yohann

jbarrez
Star Contributor
Star Contributor
No, that construct isnt available.

zze_one
Champ on-the-rise
Champ on-the-rise
Thanks Joram.

so here I am now.
In my bpmn file I have the following user task
<code>
<userTask id="usertask1" name="First User Task" activiti:candidateGroups="management, accountancy">
  <extensionElements>
       <activiti:executionListener class="realfoundation.foundationservices.process.tasks.FoundationTaskListener" event="start">
        <activiti:field name="involvedUsers" expression="${organizers}" />
       </activiti:executionListener>
     </extensionElements>
    </userTask>
</code>

I did create a Listener, in which I retrieve the value passed in my process variable for 'organizers'
<code>
public class FoundationTaskListener implements ExecutionListener {

    private Expression involvedUsers;

@Override
public void notify(DelegateExecution paramDelegateExecution) throws Exception {

        if (involvedUsers != null) {
            System.out.println("involvedUsers: " + involvedUsers.getValue(paramDelegateExecution).toString());

        }

}

}
</code>

In order to set and retrieve involved users on a task, my guess is that I have to add the value as an identyLink. I'm not sure how to do that though. Could you please help me on this ?

Thanks in advance,

zze_one
Champ on-the-rise
Champ on-the-rise
By simply doing … ?
taskService.addGroupIdentityLink("taskId", involvedUsers.getValue(paramDelegateExecution).toString(), "type"); !

I should have dig a bit more before asking apparently.

zze_one
Champ on-the-rise
Champ on-the-rise
I'm missing something.

Frederik said :
Add an execution-listener on the process (event=start), which implementation involves people with the process.
Use field-injection (again, see userguide) to define, for example, a comma-seperated list of users in an on that executionListener

so far so good.

But then, when reaching the execution listener, it looks like the task has not been instantiated yet (I made the check by listing the task instances for the given process instance).

So how is it possible to add IdentityLinks to the task instance at this point ?

What I'm trying to do :
<code>
            for (String group : transformInvolvedActorsToList(involvedGroups.getValue(execution).toString())) {
                execution.getEngineServices().getTaskService()
                        .addGroupIdentityLink(execution.getCurrentActivityId(), group, InvolvedUsersConstants.INVOLVED_GROUP);

            }
</code>

And obviously, the system cannot find any task with the provided id …

Thanks in advance

zze_one
Champ on-the-rise
Champ on-the-rise
Hi asked my question again (in a better English maybe) in this new topic :
http://forums.activiti.org/content/identitylink-and-execution-listener

thanks

vahidg
Champ in-the-making
Champ in-the-making
Hi all,

After reading the comments in this thread and the other thread that Yohann has linked to, it is still unclear to me whether it is possible to get access to the current user task in an <code>ExecutionListener</code>. In <code>TaskListener</code> this is possible through the <code>DelegateTask</code> parameter but is it also possible in <code>ExecutionListener</code> using a task query?