Get Name of destination user from the AD Group dynamically who completed the activity


Badge +2

Hi People :)


I am trying to obtain the display name of the person who completes the particular activity. Suppose, my active directory 'A' contains IDs A1, A2, A3 etc. The destination users for a particular activity is set to all the users in the AD Group 'A'. The task is assigned to A1, A2, A3 etc. A2 completes the task first and thus the task expires for the rest of the members in the group.


When A2 completes the task, i want the name of A2 to be displayed. I will display it through a smart object event and a server event. I want to display "Task completed by <Display Name>" i.e. "Task completed by Mike" (A2 = Mike)


I tried out a few things.


1) There is an OOB Smart Object "Users and Groups". This has four list methods. When i use Get_E_mail_For_Group_Users, i can obtain the display name. However, i will have to send the AD Group Name as Group Fully Qualified Name and Domain Name i.e. 'K2'.  However, i do not based on what values i can filter for the correct Display Name because there is no Process ID or Activity Name on which i can filter :(


2) The same OOB Smart Object "Users and Groups" has another method i.e. Get_E_mail_For_User. When i pass the Fully Qualified Name of the user, i get the Display name. However, i am unable to implement in code :( I can pass the fully qualified name from the Activity Destination Instance OOB Smart Object filtering based on Activity Name and Process Instance ID.


When i implement in code to obtain the display name from Get_E_mail_For_Group_Users, it is working fine. However, if i implement the same piece of code for Get_E_mail_For_User, i get an error at ExecuteList() method stating, it should be set to a method name instance.


I further checked the XML of the smart object. The methods Get_E_mail_For_Users and Get_E_mail_For_Groups are of type 'read' and the other two methods are of type 'list'. Is there another way to implement the code?


Kindly help me out.


Thank you in advance :)


Sravanthi


18 replies

Badge +13

Try the one in Workflow Reports, Activity Instance Destination.   Status of Completed and Final Action should be filled in.


Execute w/o any parameter to see what returns.


The user running this SmO must have Admin or View rights to the process.   I might be experiencing caching issue since I can see some items of a process but not others (even after I added myself as admin to the process).

Badge +2

I am trying to get the value from the Activity Instance Destination in the workflow reports SmartObject. In the smart object tester, it is populating as desired. The same is not reflecting when i try to get the value in the database using a smart object method :'(


Another funny thing, I am not able to figure it out for the life of me! In the object browser from the workflow context browser, i am taking the 'Name' from Activity Destination Instance and using it in a mail event. For one of the kprx, i am getting the desired value i.e. fully qualified name of the user who has completed the activity. However, reproducing the same in another kprx, the value for the same is being populated as K2 Server! :'( :'(


The person who initiates the process, completes the activity, everybody involved has start and view rights to the process. Still, i am not able to understand.


I tried comparing the two files using their source code. It is way too tedious and a complex approach! :( I'm at my wits end as to what i must do! :(


Help!

Userlevel 3
Badge +16

This is similar to what I'm trying to achieve> Did u get a solution or did you get past your wits end?

 

K2 Support said to use the activity instance destination smartobject to retrieve the approvers name. Anyone done this and able to share how its done?

Badge +8

@Sharpharp1: As suggested by both this thread and K2 Support, you need to use the Activity Instance Destination SmartObject.

 

Try executing this SmartObject using the SmartObject Service Tester tool on a prticular process instance.  Be sure to note the process rights needed as @PeterYao mentioned.

 

One other item to note when tasks are assigned to an AD group or K2 role: each activity assigned to a group/role will have two Activity Instance Destination results.  One will be for the group and it will have a Status of Expired when the task has been completed.  The second will be for the user who completed the task and will have a Status of the Completed once a user has completed the task. 

 

This is useful because the two activities will have different start times.  The user's record doesn't start until they actually open the worklist item to take action, where as the group's record starts when the activity is first started.  This can be useful information to, e.g. determine how long a task sits in a queue before a user opens the task.

Userlevel 3
Badge +16

Used the SmartObject Tester (see below) Is this the right Smartobject?

 

But that only shows the destination AD group when i execute List.

I need the actual name of the Approver from the AD group who approves the task.

 

12819i60C928CEFEDFF7F6.jpg

Badge +8

The second record will not be added until the task has been completed. 

 

See the attached image.  Note that the first two activities are assigned to groups of users (K2 roles in my case), so there are two records for the completed activities.  The Destination field that is blocked out for privacy contains the AD account of the person who actioned the task.  The Pending Charge Approval activity is assigned to an individual, so there is only one record for that task.  The Product Acquisition Process is assigned to a group but has not been completed, so there is only a single record for that task.


16511i1C918BFA47150EFB.png
Userlevel 3
Badge +16

Thanks for that explanation, makes sense.

 

I tried it with sending a request to an AD Group (two approvers in it).

 

Using the SO Tester, I can see the Active Status of the two Approvers (is this right? Should it appear as individual users or should it be a Group?). If Approver 1 approves the task, the SO Tester shows completed status for Approver 1 and Expired for Approver 2. Is that right?

 

Also, in the SO Tester, under destination its shows the Approvers AD LoginID rather than the Approvers Name, how do i get the actual approvers name?

 

In terms of my K2 Studio Workflow, how do i pluck that "completed Approver" field into a variable to use in my Workflow to send an email to the Approver Group to say which Approver approved the request?

Badge +8

The exact data you see probably depends on how your activity is configured.  Our activities are configured as plan just once with a single destination slot.

 

In the case you mentioned, which ever user actioned the task will have a status of Completed and the other should have a status of Expired.  Its also important to note that the status of Completed does not mean the user approved the item.  The exact action taken by the user is in the Final Action column.

 

To get the user's real name from AD, you can use the GetUserDetails method in the UMUser SmartObject.

 

If you only need the user's name in one email, I would simply use an email event and drag the SmartObjects into the body of the email using the workflow context browser.  If you need to keep the user's name around after the email is sent, you can use a SmartObject event to assign it to a process data field.

Userlevel 3
Badge +16

Sorry i don't understand this.

 

Can you do an example plz?

Badge +8

Which don't you understand?  What do you need an example of?

Userlevel 3
Badge +16

The bit I don't get is the part of getting the Approvers Name into the email.

 

In my email event, i put this in the body...

 

This has been approved by: Activity Instance Destination List Destination.

 

I ran the form and send the approval to an AD Group (for example lets say it has 2 Approvers in it). Both receive the request. Approver 1 replies to the email with Approved. Then I want to send an Email to the AD group saying Approver 1 has approved the request and not to take any further action.

 

The email does get sent to the AD group, but the outcome is:

 

This has been approved by: name of end-user (not the Approvers name)

 

How do I actually get Approver 1's name into my Email Event? This is not working.

 

Do I have to do something with this bit?

 

16894i1701090FAF672813.jpg

 

Almost seems like my returned value isn't the one for the actual Process ID, so using the above wizard, how do i configure it so it pulls the correct UserID of the person who approved/declined THIS request?

 

Hope that explains it.

(phew i need a drink after this post)

Badge +8

OK two things:

 

First, you aren't filtering the Activity Instance Destination SO correctly.  What you are asking for right now is any activity in any process instance who'se Final Action is either Approved or Rejected.  Add filters on the Process Instance ID and Activity Name to get the proper result (see attached soFilter.png).

 

Second to get the user's real name, start by dropping the Get E-mail for User SmartObject into your email (see attached getDisplayName.png).  This is the UMUser SmartObject in the SO Service Tester app, but for some reason, K2 calls it something different in the designer.  Even though it is called Get E-mail for User you can return the Display Name property of the user.  On the input mapping, click the User Fully Qualified Name parameter, then click Assign.  In the Value field, drop the Activity Instance Destination SmartObject with the filters mentioned above, and that should get you there.


15440iC69BE6DD6EAFA9EB.png
11224i492D32A2DE48F52A.png
Userlevel 3
Badge +16

Hello,

 

In sofilter.png... Where do you the "ProcessId" in the first line from? -Did u type it in or drag from Context Browser? If so, which object?

 

For line 2, I got the Activity Name from the Smartobject Tester

For line 3, I manually typed in Completed

 

Thanks

 

 Actually, I think I got the Processid, can you confirm if I got it from the right place below?

Update: I just tested this part, but there is no value returned in the Email, its blank when the approvers receive it.

Message just says: This has been approved by:

 

14838i0133B881A353207D.jpg

Badge +8

Yes, the ProcessId is picked up from the Context Browser.

 

Using the SmartObject Tester, what results to you get for your process?  Execute the List method of the Activity Instance Destination SmartObject.  Supply just your process instance ID and post the results (see attached).


11117iFFBE9DC36093D2FE.png
Userlevel 3
Badge +16

The List Results shows Process Instance ID 3648

 

Also other fields are:

 

Activity Name - DefaultActivity

Destination - K2:DomainUser ID of the Approver

Status - Completed

Activity ID - 3267

Final Action - Approved

 

Badge +8

Start by trying to output just the Destination from the Activity Instance Destination SmartObject in your email (and maybe a count).  That will tell you if you are at least getting the correct results.

 

If you have the correct results from the AID SO, then you can start worrying about getting the real name.

Badge +8

Almost forgot....

 

Make sure the K2 service account has View rights on your process.  The AID SO will not return any results without View or View Participate rights.

Badge +7

Hey,

 

the best i would think of is, set the destination set to Plan per slot and also  set it all at once, then right after the user completed the action, call an data event to capture the Participant user name, Patircapant datafield will by default appear in the activity level, you dont have to define one ( you can also find this one in the workflow context tab).

 

Hope it helps!

 

cheers,

Prajwal Shambhu

Reply