How to assign user role dynamically based on dropdown control value in the view

  • 14 December 2015
  • 6 replies
  • 4 views

Badge +9

HI,

Assigning user role to destination activity is little tricky for us and we do not know how to do it. May be I can get help here. We have Manager approval roles MA1,MA2,MA3 ..... etc. These manager approval role need to be assigned at run time based on the StoreNumber being selected at the form level view storenumber dropdown.

 

Scenario:

 

At Data entry activity level, user select the StoreNumber from the dropdown list. Then it looks at the Database table (ManagerApprovalTask) to assign the role dynamically. It all happens at the backend, no user interaction is needed.

 

Ar ManagerApproval activity, assigned worklist item is ready for approval. Manager should be able to see all those worklist items assigned to him in his inbox in SharePoint.

 

Database table is simple:

 

StoreNumber                           ManagerAapprovalRole

=========                            ================

2001                                            MA1

2002                                            MA2

2003                                            MA3

 

Is there any way we can accomplish such dynamic role assignment ?

Thanking you and looking forward for some insights.

 

 


6 replies

Badge +7

Hey,

 

If i understand your scenario correctly it should be done calling K2 SmartObjects in the destination set and passing the store number as filter parameter for the list method.

 

My understanding about the scenario:

 

You have data table which saves different Manager role ( when you say role i assume you are not talking about K2 Role) for each Store Number.During the time of creating the request you select Store Number from the Dorpdown list. Based on the Store Number selection respective Manager role users should get assigned with the task.

 

Resolution:

 

1) Once you select the store number from the dropdown list, pass this data from form level (user interface level) to Process level, lets say you save this information in the Datafield called StoreNumber.

2) At the activity destination Users, call the smartObject  GetList method which connects to Sample Data table (as per your scenario) and do inputting mapping with the Datafield StoreNumber and return the first record.

 

with the above steps you should be able to pick Manager approvers information dynamically.

 

 

Hope it Helps!

 

Cheers,

Prajwal Shambhu

 

Userlevel 5
Badge +16

Hi,

 

 

I believe you are using the above table as the data source of your dropdown list.

 you can easily create a datafield on your process and spret it as destination of Role type and on the process start action map the role name to the destination data field

 

If I'm correct that you're using the same table as the data source of the drop down list then this is how to find the role name:

 

14958i14EDF2F8177580E9.png

 

you don't need to execute SMO method calls.

Badge +9

Thanks Prajwal,

That's really a quick response. You have exactly understood the scenario what I am trying to do, dynamically assign the role from the table based on the Storenumber. However, I see a missing hole here, should I have to create a same role in the K2 workspace user manager? Once I have the role from the smartobject getlist, how do I map to the K2 user role ?

 

Thanks.

Badge +9

HI Mustafa,

StoreNumber data source is different from the one where ManagerApprovalRole is defined in a seperate table. Once the StoreNumber is selected, then we need to pull the AmanagerApprovalRole from the different table where that StoreNumber is used as filter. Once we have that ManagerApprovalRole, then it should match with the K2 user defined role and associate to the task. If this is the right approach, I do not know how to accomplish the same in the K2 blackpearl using VS.

 

Thanks.

Badge +7

Hi,

 

Yes you can dynamically assign roles;

 

Say for instance i have a tabl with Store Numbers and respecitve as its Role names available as shown below;

12486iE391A171D3A590BE.png

 

NOTE: Since you are using K2 Roles, please make sure the roles are created in the K2 workspace, for instance as per my example i have three K2 roles defined in my k2 server like below;

11595iA790C60484BD85A1.png

 

This way you can assign tasks to K2 Roles dynamically.

 

 

Hope it helps!

 

Cheers,

Prajwal Shambhu

Badge +9

Thanks Prajwol,

I could able to assign the user role dynamically based on the StoreNumber mapped to the user role table and assign the role into the Role Datafield.

Your approach helped me a lot. Thanks once again.

Reply