Hello,
This code will work >D
Change name of role as you need
this example use "APPROVER" as checked role.
wt.workflow.engine.WfProcess wfprocess = (((wt.workflow.work.WfAssignedActivity) self.getObject()).getParentProcess());
java.util.Enumeration roles = wfprocess.getRoles();
while (roles.hasMoreElements())
{
wt.project.Role role = (wt.project.Role) roles.nextElement();
java.util.Enumeration participants = wfprocess.getPrincipals(role);
// kontrola zobrazovaného názvu role
if (role.getDisplay().equalsIgnoreCase("APPROVER"))
{
wt.org.WTPrincipal activeUser = wt.session.SessionHelper.getPrincipal();
if (!participants.hasMoreElements())
{
String msg = "Approver MUST be assigned";
java.lang.Exception exp = new java.lang.Exception(msg);
throw exp;
}
while (participants.hasMoreElements())
{
wt.org.WTPrincipalReference principal = (wt.org.WTPrincipalReference)participants.nextElement();
wt.org.WTPrincipal assignedUser = principal.getPrincipal();
if (assignedUser.getName().equals(activeUser.getName()))
{
String msg = "Can not set yorself as Approver.";
java.lang.Exception exp = new java.lang.Exception(msg);
throw exp;
}
}
}
}
PetrH