05-12-2017 07:39 AM
My process flow requires a manager to review an analyst's work and, if changes are needed, the manager can return the case to the same analyst or a different one. When changes are needed, I'd like to display the analyst's name to the manager and allow them to accept this analyst or select a new one.
When the analyst is originally assigned the task to do the work, I set a process variable "requestAssignee" and the task to do the work is assigned using that process variable. This variable contains the id of the user. On my manager form I have a People control that I default to the person associated with the "requestAssignee". Setting the People control to the value in "requestAssignee" causes the id of the user to be displayed. If the manager doesn't change the value in the People control, when completing the form, flow proceeds to the do work task but it isn't assigned to anyone. If the manager changes the analyst to a user, that user is properly assigned the do work task. How can I default a People control to a user so that it displays the user's name and can be used for the task assignment without the manager changing it?
For additional reference, I'm using form mappings to set the value of the analyst in the manager form:
Thanks
05-12-2017 10:58 AM
05-16-2017 04:01 PM
Thanks much for your answer. I was unable to import your sample, but by reading the xml and json files, I was able to mimic your prototype and this solved my initial issue.
There is still one scenario where I'm trying to set the assignee and it's still displaying as a number on the Manager's form. When the Do Work task is assigned to user 1, user 1 can use the built in capability on the top of the form to reassign the task to another user (i.e., user 2). User 2 works the task and it proceeds to the manager. The People control on the manager form now should display user 2's name. I've tried adding the following javascript to the Do Work task Complete task listener
task.getExecution().setVariable('requestAssignee', task.getAssignee());
But this causes the user's number to be displayed on the manager's form instead of the name.
Thanks
05-16-2017 05:32 PM
When you say it causes the users number (I assume id) to be displayed on the manager's form, what type of form field are you using? If you are using a People selector then it will show the user name not the id.
If you are displaying it in a regular input or text field, then indeed it will display the user id.
If you need the user name or email address, you need to use the userService to get that information.
Greg
05-16-2017 09:21 PM
I'm using a People control on the Manager form. It's defined as:
"fields": {
"1": [{
"fieldType": "FormFieldRepresentation",
"id": "requestAssignee",
"name": "Display Assignee",
"type": "people",
"value": null,
"required": false,
"readOnly": false,
"overrideId": true,
"colspan": 1,
"placeholder": null,
"minLength": 0,
"maxLength": 0,
"minValue": null,
"maxValue": null,
"regexPattern": null,
"optionType": null,
"hasEmptyValue": null,
"options": null,
"restUrl": null,
"restResponsePath": null,
"restIdProperty": null,
"restLabelProperty": null,
"tab": null,
"className": null,
"params": {
"existingColspan": 1,
"maxColspan": 2
},
"dateDisplayFormat": null,
"layout": {
"row": -1,
"column": -1,
"colspan": 1
},
"sizeX": 1,
"sizeY": 1,
"row": -1,
"col": -1,
"visibilityCondition": null
}
On the Do Work task that is immediately before the Manager form, I have the following task listener for the complete event:
"formreference": {
"id": 15027,
"name": "Do-Work",
"referenceId": null,
"variablesmapping": []
},
"fieldstovariables": "",
"duedatedefinition": "",
"prioritydefinition": "",
"categorydefinition": "",
"formproperties": "",
"tasklisteners": {
"taskListeners": [{
"event": "complete",
"implementation": "org.activiti.engine.impl.bpmn.listener.ScriptTaskListener",
"className": "org.activiti.engine.impl.bpmn.listener.ScriptTaskListener",
"expression": "",
"delegateExpression": "",
"$$hashKey": "uiGrid-000H",
"fields": [{
"name": "language",
"implementation": "javascript",
"stringValue": "javascript",
"expression": "",
"string": "",
"$$hashKey": "uiGrid-000N"
},
{
"name": "script",
"implementation": "task.getExecution().setVariable('requestAssignee', task.getAssignee());",
"stringValue": "task.getExecution().setVariable('requestAssignee', task.getAssignee());",
"expression": "",
"string": "",
"$$hashKey": "uiGrid-000T"
}]
}]
},
When the manager form is displayed, the id shows in the People control instead of the name:
05-19-2017 11:32 AM
05-19-2017 05:05 PM
Attached is a sample process flow where the user's Id is displayed instead of their name. To reproduce, on the "Do Work" form, change the Assignee. Log in as that assignee and complete the "Do Work" task. Log back in as the initiator to see the Manager Review form where the people control displays the Id instead of the name.
05-22-2017 01:00 PM
06-16-2017 05:20 PM
Thanks
Lauren
Explore our Alfresco products with the links below. Use labels to filter content by product module.