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.

Example:

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

1.Workflow

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.

2.JoinFunction.jpg

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.

3.UMUsersSMO

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

4.Final.jpg

 

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.

7.Default

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.

9.SplitDataField.jpg

Now final screen should like below

ClienteventFinal.jpg

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.

Author: Vijay

I'm a K2 Certified Developer, helping teams to automate, design, develop & maintain business process applications connecting across multiple platforms with multiple technologies.

Leave a comment

Bagi2info.com

Tips dan Trik Komputer, Tutorial Pemrograman, SQL, PHP, React Native - Expo

Mohamed Ashiq Faleel

Its time to think about Microsoft 365

Common Man Tips for Power Platform, Dynamics CRM,Azure

Venkata Subbarao Polisetty - Microsoft MVP,C# Corner MVP

James K2 Blog

Tips and Tricks about K2 workflow software

the BPM freak !!

"The illiterate of the 21st century will not be those who cannot read and write, but those who cannot learn, unlearn, and relearn" – Alvin Toffle

Start Rule

Learning K2 blackpearl and K2 Five

K2Ranger

Do K2 like a BOSS!!

Maverick

discover your own way and lead the world... with Divya Raj

jeylabs

Work Intelligently

Chasing Time - Mobile Gaming Photography Tips Tricks

#iamtheiosphotographer Pro Mobile Game Reviews, Tips, Tri

Jozsef Torsan

Founder & Software Engineer - Creator of the Bookmark Ninja Online Bookmark Manager

GreenEggs on K2

Saving the world with K2