Handling multiple destination users dynamically from multiple sources.

Hello Friends,

This post is about handling multiple destination users dynamically from multiple sources.

Multiple Destinations.png

Generally we come across this situation while developing workflows, where based on some business rule or condition we need get the users from multiple sources for assigning tasks, Here I’m going to take similar type of situation as an example and will explain you how we can achieve it.


I have a student Admission Workflow in which there is an Approval Activity called Branch Approval. Now for assigning users to this Branch Approval Activity, I need check the Branch of the student and then get the users based on it. Here in this case of my requirement I have a K2 Role and an Active Directory Group and a Constant Value from where I need to get the destination users based on branch condition.

Requirement is something like below:

If Branch is

CSE then assign the task to users from K2 Role,

ECE then assign task to users from AD group users

Others then assign task to a constant user.

Now to achieve this I’m also making use of K2 inline Functions Join and Split. 

Also you refer this link How to create K2 Roles to see how we create and use K2 Role.

let’s start and see how we can do this.

Below is the workflow screenshot


Step 1: Create a new Data field with name Destination of string type, to hold the users that we fetch dynamically.

Step 2: Draw 3 lines for 3 Data Events as shown above and LineRules should be set based on data field Branch.

Step 3: Now in activity Get CSE Users, Drag a Data event and follow below steps

Step 3.1: In source field Drag JOIN function from FunctionBrowser under Text Category.


Step 3.2: Now in values field, you need to open SmartObject Explorer, navigate to System/Management/SmartObjects category and open UMUser Smartobject and select Name field from its Get Role Users method. Once you select it will ask for RoleName, pass role name and click Next and select Return all results option and click Finish. And in separator type semicolon “;” as shown below and click finish.


Step 3.3: Now in Destination field drag Destination Datafield created in step 1 and final screen should look as below Next Click Finish.



Step 4: Now similar to what we did above follow the same steps for the activity Get ECE Users, only difference would be the SmartObject that we are going to get users. As in here my requirement is to get users from AD Group if Branch is ECE, so I’m using below SmartObject to do the same.

SmartObject Name: AD Users

Category: SmartObject Server(s)/SmartObject Server/Active Directory/

Method Name: GetUserByGroup

5. ADSMO.jpg

Once you are done then the screen should like below and click finish.

6. ADFinal.jpg

Step 5: Now moving to activity Get Default Users as per our requirement if branch is OTHERS then assign to some default User so in data event source field I have hardcoded a username and assigned it to data field Destination. Screen should look as below.


I suggest you to get this constant value from some Database or some configuration setting so that it would be easy for use to change or modify this value without redeploying the workflow

Also you can assign to multiple default users by passing them as a semicolon separated string like Domain\\User1; Domain\\User2;

Step 6: Now drag a Client Event give it a name and in Destination Rule option drag SPLIT function from Function Browser under Text category.

8. Split

Now drag the Destination Data field in text field and in separator type Semicolon “;” as shown below.


Now final screen should like below


Now click Finish, configure Actions and then complete and deploy the workflow.

That’s it!! Now test the workflow to see different cases and destination users picked from different sources as per the branch.

This is how we can handle multiple destination users from multiple users dynamically.