Expand my Community achievements bar.

Getting Current Participant in a Workflow Process

Avatar

Former Community Member
Hey Workflow wizards,



How do you get the current participant's name in a workflow process? Using Task.AssignedTo doesn't always work because if someone has access to someone else's worklist and opens a work item from that person's worklist, Task.AssignedTo will not report the correct participant. Any ideas?



Thanks.
11 Replies

Avatar

Former Community Member
Hi Perry,



I think you'll want to use the WorkItem.CompletedBy property, which returns the participant object for the person who actually completed the task.



So you could use something like:



var sName = WorkItem.CompletedBy.Name();



Hope this works for you,

Sanna

Avatar

Former Community Member
Hi Sanna,



I had thought of that, but it will only work once the workitem is completed. I actually need to get the value of the user when they open the workitem but before it is completed. Any ideas?

Avatar

Former Community Member
Perry,



That is a scenario I have not had before, and I can see your dilemma. Even the other options available at onOpen event, Role.CurrentParticipant.Name and getParticipant(Role.name) method only return the name of the shared worklist.



Unfortunately I do not know how to do this - but am interested to learn how if you ever find it out, so pls keep us posted.



Tahnks,

Sanna

Avatar

Former Community Member
You can probably code something in client script to get the ID from NT authentication.

Avatar

Former Community Member
That might work, but I'm not using NT authentication.



I think I've found a workaround for this case, but here's the next thing I want to do: get a list of all users who have access to the current user's worklist. Any ideas?

Avatar

Former Community Member
Perry,



More bad news - The only way I can think of for finding that out is via the API - which you cannot access directly from the Process script.



On a brighter note, you can access it from the form (specially if you are using form server that has the Workflow server object library installed). Or you could write a DLL or something to wrap the call and call that from your process map, if you prefer.



Check out the Objectlibrary.pdf and look for table definition for WorklistShares table, that looks like giving you what you want.



Good luck,

Sanna

Avatar

Former Community Member
Hi,



Try to use XML DOM via XMLHTTP post. In an ASP page, code the required APIs that will return the result in a XML DOM. Call this ASP via XMLHTTP from any where (from side and the server side.) This method is proven to be very handy in many cases.



Regards,



Yasser

Avatar

Former Community Member
Perry,



Concerning your first question - "How do you get the current participant's name in a workflow process?"



You will need to edit the WorkOnTask.asp located in ( ..\WebAccess\Web ) which is responsible for the merging\rendering of form\data. Add the following line around line 28, just after the destruction of the rs.



xmlData.SetField("WF_CURRENTLOGON", theUserName);



Now, on the XFA template add a field called "WF_CURRENTLOGON" and youre done. Note: This field will populate with the current wf particpant that has rendered the form ( great when using SWL ).



On your second question - "Get a list of all users who have access to the current user's worklist."



Building off of the last entry, within an ASP you can query the WorklistShares Table using the EPSDK, this should return a list of users per SWL. This could be called from either the Process or Form Template.



Enjoy.

Avatar

Former Community Member
Hi Jon,



Thanks, actually my first issue went away but I'm still working on the second issue. See my post about calling an ASP from a process map. I've created an ASP that gets the user list from the WorklistShares table but I'm having trouble calling it from the process map. BasicScript doesn't seem to like the XML object properties and methods such as .async, .load and .getelementsbytagname.

Avatar

Former Community Member
Use var oParticipantCompletedBy = WorkItem.completedBy;

to distinguish from WorkItem.assignedTo.

Avatar

Former Community Member
Actually Peter, using WorkItem.completedBy will only contain a value within the OnComplete() for that particular Task. This will not work if you wish to grab the name of the current user who has locked a work item (ie. has it open).