cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain the group of a user within a workflow?

Highlighted
Level 1

How to obtain the group of a user within a workflow?

I need to obtain the group or groups of the user that is performing an activity, actually I dont know how to cast the pbo in order to do obtain this.

Also I was thinking that I could use a role to obtain the user that initiated the workflow but I dont know how to obatain the username, also i dont know how to obtain the group.

Do you guys, have any ideas?

Regards

Emyr

Tags (3)
1 REPLY 1

Re: How to obtain the group of a user within a workflow?

This might help you get started. This code finds the assignees for a workflow activity.

String name[] = new String[100];

for (int j=0; j<name.length; j++){name[j] = null;}

int i = 0;

try

{

wt.workflow.work.WfAssignedActivity wfact = (wt.workflow.work.WfAssignedActivity) self.getObject();

java.util.Enumeration assignments = wfact.getAssignments();

while (assignments.hasMoreElements())

{

wt.workflow.work.WfAssignment assignment = (wt.workflow.work.WfAssignment) assignments.nextElement();

java.util.Enumeration principals = assignment.getPrincipals().elements();

while (principals.hasMoreElements())

{

wt.org.WTPrincipalReference wtpr = (wt.org.WTPrincipalReference) principals.nextElement();

name[i] = wtpr.getDisplayName();

i++;

}

}

}

catch(java.lang.ClassCastException cce)

{

throw new WTException("Only WfAssignment objects can get assigned Principals" + cce);

}

To find the groups that the user belongs to, you can use the wt.org.OrganizationServicesHelper.manager class to find methods for retrieving that info.

Hope this helps.