0
votes

I'm trying to create a custom workflow, where at the start of the workflow, the workflow initiator can choose 3 users to perform different tasks in the workflow (in this case, an author, a reviewer, and an approver).

To do this I am defining each of these roles as an aspect of my start task in my workflow model, and then I am trying to assign these users to process variables in the workflow and assign the tasks to them through the activiti:assignee task. In my share-config-custom I am defining the roles as authority controls. I am following the process described in: Multiple assignee controls in Alfresco Workflow form

The workflow starts without a problem, and Alfresco allows me to select users, but the task assignment does not work. In the workflow history, it says that the task is assigned to "$(author.properties.userName)", which is the expression I use in my bpmn file, but it is not picking up the userName of the author variable.

I have attached links to my files below. If there is a problem with them, or if there is a better method of achieving this goal, please let me know!

Many thanks

Marcus

bpmn file: https://drive.google.com/file/d/0By5ruty8M4IleWlKSmdQNUNXR0k/view?usp=sharing

workflowModel file: https://drive.google.com/file/d/0By5ruty8M4IlVEFlSWo2SElNNUE/view?usp=sharing

I will post the share-config-custom in the comments

2
Did you try reviewing the BPMN files of the built-in Alfresco workflows, to see how it's done there?Gagravarr
task.getVariable('vorwf_author') you are trying to get author by using this. can you please explain this line returns userName???.vikash
@Gagravarr unfortunately I do not think there is an example workflow where you can choose multiple assignees. All the workflow use bpm:assignee which only works when there is one assignee in the task...Marcus Collier-Wright

2 Answers

1
votes
execution.setVariable('author', task.getVariable('vorwf_author'));

you are setting a variable author and you are trying to assign a task to author by using $(author.properties.userName)

here author is not an object so you can not find userName. if you wanted to do it so you have to create user object

example : enter your user name

 var author=people.getPerson("user_name");
 var authVar=author.properties.userName;

set variable

execution.setVariable('my_author',authVar);

and you can access it by using ${my_author}

Or

if you are getting userName of author by this task.getVariable('vorwf_author')

 execution.setVariable('author', task.getVariable('vorwf_author'));

then you can simply use ${author}

1
votes

I've managed to figure out how to do this! Firstly, I define each 'role' in the workflow as an aspect in my workflowModel.xml file. Here is an example for one of the roles, author:

<aspects>
    <aspect name="vorwf:author">
        <associations>
            <association name="vorwf:author">
                <source>
                    <mandatory>false</mandatory>
                    <many>false</many>
                </source>
                <target>
                    <class>cm:person</class>
                    <mandatory>true</mandatory>
                    <many>false</many>
                </target>
            </association>  
        </associations>
    </aspect>

I then set these roles as mandatory aspects in the definition of the task where the user roles are defined:

 <type name="vorwf:allocateDocumentProperties">
        <parent>bpm:startTask</parent>
        <properties>
            <property name="vorwf:approveRejectOutcome">
                <type>d:text</type>
                <default>Reject</default>
                <constraints>
                    <constraint type="LIST">
                        <parameter name="allowedValues">
                            <list>
                                <value>Approve</value>
                                <value>Reject</value>
                            </list>
                        </parameter>
                    </constraint>
                </constraints>
            </property>
        </properties>
        <mandatory-aspects>
            <aspect>vorwf:author</aspect>
            <aspect>vorwf:reviewer</aspect>
            <aspect>vorwf:approver</aspect>
        </mandatory-aspects>
    </type>

Finally, I can assign the task to the user in my bpmn file, without having to set any other variables, for example:

<userTask id="prepareDocument" name="Prepare Document" activiti:assignee="${vorwf_author.properties.userName}" activiti:formKey="vorwf:prepareDocument">