This tutorial explains how to dynamically assign a task to the user manager.
Prerequisites
- Start by following this HOWTO: Add New Fields to the User Profile or Group Profile.
- On your Studio project, in Modeler > External Templates, install the Default Nuxeo Platform Configuration template.
Use Case
We create a simple workflow template with only one validation task, sent to the document creator manager.
Create a Document Property to Store the User Manager
To complete this use case, we use a technical document property to store the manager information. For this tutorial, we will use the File schema, and create a file_schema:manager property, of type User/Group, with a restriction to be exclusively a User.
To do so:
- In Modeler, go to Content Model > Document Types and click on File.
- Go to the Schema tab and add a new field manager, typeUser/Group.
- Save your modifications.
Create a Workflow Template
- In Modeler, go to Workflow and create a new workflow:- Feature ID: WF_Automatic_Task_Assignment
- Label: Automatic Task Assignment
 
- Feature ID: 
- Click on Ok
- Go to the Graph tab and drag and drop an Approve task.
- Edit the task, and on the field Assignees expression put:Document["file_schema:manager"]
- Click on Save
- Connect the Start and End points to the approve task and save your modifications.
Create the Automation Chain
- In Modeler, go to Automation > Automation Chains and create a new chain Set_WorkflowManager.
- Click to Switch editor at the top of the page and copy/paste the following chain:- Context.FetchDocument - Document.SetProperty: xpath: "file_schema:manager" save: "true" value: "@{CurrentUser[\"user:manager\"]}"
- Save your modifications.
Create the Event Handler
- In Modeler, go to Automation > Event Handlers and create a new event handler EH_AC_SetAssigneeTask:- Events: Document created
- Current document has one of the type: File
- Chain or script: Set_WorkflowManager
 
- Save your modifications.
Generate the Workflow Task Layouts
- Navigate to Designer > UI > Layouts > Workflows > and click on Configure Missing Layouts. 
- Save your modifications.
Deploy and Test your Configuration
- Deploy your changes.
- Create a user bossand a userjdoe, and setbossasjdoe's manager
- Log in as jdoeand create aFiledocument type.
- Launch the Automatic Task Assignment workflow on it.
- Log out and log in as boss. The userbosshas a validation task!