I'm required to build a workflow that allows the admin to select two assignees from two different groups in the first task of the workflow. Can I use two assignee controls in one form ? How?
3
votes
1 Answers
5
votes
You need to:
In the task content model, define the 2 assignees as 2 seperate associations of your task type.
<type name="my:starttask"> <parent>bpm:startTask</parent> <associations> <association name="my:firstassignee"> <title>firstassignee</title> <source> <mandatory>false</mandatory> <many>false</many> </source> <target> <class>cm:person</class> <mandatory>false</mandatory> <many>false</many> </target> </association> <association name="my:secondassignee"> <title>secondassignee</title> <source> <mandatory>false</mandatory> <many>false</many> </source> <target> <class>cm:person</class> <mandatory>false</mandatory> <many>false</many> </target> </association> </associations> </type>
In your share config custom, define the 2 associations as authority controls:
<config condition="activiti$myworkflow" evaluator="string-compare"> <forms> <form> <field-visibility> <show id="my:firstassignee" /> <show id="my:secondassignee" /> </field-visibility> <appearance> <field set="actors" id="my:firstassignee" > <control template="/org/alfresco/components/form/controls/authority.ftl"> </control> </field> <field set="actors" id="my:secondassignee"> <control template="/org/alfresco/components/form/controls/authority.ftl"> </control> </field>
In your bpm20 file, define two ActivitiScriptNode vars in your process and an ExecutionListener to the usertask/starttask having the two cm:person associations. That execution listener should be taking the entered values and placing them into the process scoped variables like this:
<extensionElements> <activiti:taskListener class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener" event="complete"> <activiti:field name="script"> <activiti:string> execution.setVariable('firstActivitiScriptNodeVar', task.getVariable('my_firstassignee')); execution.setVariable('secondActivitiScriptNodeVar', task.getVariable('my_secondassignee')); </activiti:string> </activiti:field> </activiti:taskListener> </extensionElements>
Then add this code to the UserTasks you which to assign to the entered users like this:
<humanPerformer> <resourceAssignmentExpression> <formalExpression>${firstActivitiScriptNodeVar.properties.userName}</formalExpression> </resourceAssignmentExpression> </humanPerformer>