You can assign tasks to users in the General tab of Properties view of the Process Definition or by setting Java Actions. If you want to assign tasks to users after the Process Definition has been designed, you can do it by setting a Java Action.
Depending on the business requirements, an activity might need to be assigned to a user who is related to the performer of a completed activity. This relationship could be manager, colleague, team leader etc. For example, Activity 1 has been completed by User 1. Activity 2 needs to be completed by the user (User 2) who is the manager of User 1. In this scenario, you can specify the relationship of User 2 with User 1 and assign Activity 2 to User 2.
Similarly, you can assign an activity to a user depending on the user names associated with the UDAs and relationships between the users. For example, Variable 1 is a String type UDA, which is associated with User 1. In this scenario, Activity 2 needs to be assigned to User 2 who is the manager of User 1. You can assign Activity 2 to User 2 by specifying this relationship in the Java Action.
Note
Only UDAs of type STRING are considered for setting assignees to activities from relationships using UDAs.
To set assignee from relationship:
Select an activity in the Process Definition which needs to be assigned to a user.
Note
You can select an Activity Node or a Voting Activity Node or a Compound Activity Node to set the Java Action on it in order to assign it to the performer of a completed activity.
Click Action Set tab of the Properties view.
The Java Action Sets area is displayed in Action Set tab. By default, Role Actions tab is selected in Java Action Sets.
Select Role Actions in the work area and click Add.
Action Type List dialog is displayed.
Double-click on the Server Actions action type.
Select Set Assignee From Relationship and click Create.
Figure 11.10 Setting assignee from relationship
The following sections describe the procedures to set assignee to an activity depending on his/her relationship with the user of a completed activity and to set assignee to a task depending on his/her relationship with the user names associated with the UDAs.
Note
Relationship Name is a mandatory field.
To assign an activity to user who has a relationship with the performer of a completed activity
Optional: Enter the name of the action in Action Name field.
Optional: Edit notes in Notes field. By default, a note will be displayed in the Notes field.
Select the Completed Activity radio button (selected by default) in Source Value Specified From. Upon selecting this radio button, all the completed activities are displayed in the drop-down list except the one which needs to be assigned to a user. The UDA Value radio button and the drop-down list are disabled.
Select the completed activity from the drop-down list.
Enter the relationship name in the Relationship Name field. For example, User 1 has completed Activity 1. User 2 is the manager of User 1. If you want to assign User 2 to Activity 2, select Activity 1 in the Completed Activity drop-down list and specify Manager in the Relationship Name field.
Click OK. In case of the above example, Activity 2 will be assigned to the manager of User 1.
To assign an activity to user who has a relationship with the user associated with a UDA
Optional: Enter the name of the action and edit notes in Action Name and Notes fields respectively. By default, a note will be displayed in the Notes field.
Select the UDA Value radio button in Source Value Specified From. Upon selecting this radio button, all the STRING type UDAs of the Process Definition are displayed in the drop-down list. Each UDA is associated with a user name
Select the UDA from the UDA Value drop-down list. For example, if you want to assign User 2 to Activity 2, select UDA Variable 1 in UDA Value. User 1 is associated with Variable 1 and User 2 is the manager of User 1.
Enter the relationship name in the Relationship Name field. Specify Manager in the Relationship Name field.
Click OK. In case of the above example, Activity 2 will be assigned to the manager of User 1 that is User 2.
Note
You can assign an activity only to the users within the Role to which the activity is currently assigned. If you want to reassign the activity to users from another Role, you must add this user to the current Role.
Note
By defining the Role Java Action, the activity is assigned to a particular user. In this case, defining the Role of the user to whom you want to assign the activity is not required. You can assign a Voting Activity and a Compound Activity in the same manner.
Note
It is not necessary to compensate this action using a compensation action, because changes made by this action are in Systemwalker Runbook Automation only and they will be rolled back after the process instance goes into error state. For information on compensation actions, refer to section 11.1.7 Dealing With Errors in Java Actions.
Relationship names
Relationship names are explained below.
After an activity has been allocated to a role, the people in that role group can then operate on the activity. If, for a particular instance, an activity has been allocated to a manager role, all members of the manager group can operate on that activity. However, in fact, only one manager will execute the activity. That manager is referred to as the "actor" for that activity.
Depending on the workflow, after an activity has been executed, there may be cases where you want to decide who will work with the activity. You may then want to take action based on that information.
For example, consider an activity called "record customer incident" allocated to the role "senior customer support staff". First it is necessary to check which of the "senior customer support staff" actually performed the "record customer incident" activity. Then, it would be desirable to allocate the same actor to the next activity called "escalate incident" within the process instance.
The ServerEnactmentContext interface of the com.fujitsu.iflow.server.intf package includes a getActivityActor() method used to determine the actor for the activity.
The actor for a completed Activity Node can be acquired by passing an Activity Node name as a parameter for the getActivityActor() method.
Voting Activity Nodes do not support this method.
It is recommended to assign a unique name to each Activity Node within a process instance. This method will throw an exception if there is a node with the same name as a node that the activity has already passed through.
The next sample code gets the actor for a past activity ("Activity A") and then allocates the same actor to the current activity.
public void assignActivityActor(ServerEnactmentContext sec){ String[] actor = new String[1]; actor[0] = sec.getActivityActor("Activity A"); sec.setActivityAssignees(actor); }
This method must be called by a JavaAction defined as part of the JavaScript. Refer to the API Javadoc Manual for details.
In certain workflows, work is sometimes allocated by referring to UDA values, or the hierarchical relationship to the activity actor. For example, if the value "Fujitsu" has been set for the UDA "company name", it is possible to allocate only the executives to particular activities by checking that the actor is the executive for the Fujitsu key. Also, if a certain activity has been allocated to an actor called "Jim", it is possible to find out who Jim's manager is and then allocate a particular activity to that manager.
Determine relationships using the resolveRelationship() method of the ServerEnactmentContext interface included in the com.fujitsu.iflow.server.intf package.
The resolveRelationship() method returns the target value by using a source (reference) value and a relationship as parameters. This method is functioned by defining the source value, the relationship and the target value beforehand. This enables the method to return the appropriate values.
Source value | Relationship | Target value |
---|---|---|
Jim | manager | Robert |
Jim | assistant | Arthur |
Fujitsu | executive | Bob |
For example, resolveRelationship("assistant", "Jim") returns "Arthur".
The mappings between source values, relationships, and target values must be stored as user profiles in either the directory service or the local user store. Here, the source value is the user ID, the relationship is a user attribute name, and the target value is a user attribute value.
To create a user profile, refer to the API Javadoc Manual for information on the DirectoryServices interface that is included in the com.fujitsu.iflow.model.workflow package.
For source values, both humans and non-humans (such as company or group names) can be set. If a user profile for a non-human object is added to the directory server or the local user store, ensure that the user profile is not used for login purposes.
The next sample code gets the actor for a past activity ("Activity A") and the Manager for that actor, and then allocates that Manager to the current activity.
public void assignManagerOfActivityActor(ServerEnactmentContext sec){ String[] managers = sec.resolveRelationship("Manager",sec.getActivityActor("Activity A")); sec.setActivityAssignees(managers); }
This method must be called by a JavaAction that has been defined as part of the JavaScript. Refer to the API Javadoc Manual for details.