Skip to main content
1-Visitor
October 12, 2011
Question

Conditional connector

  • October 12, 2011
  • 1 reply
  • 697 views

I am trying to setup a conditional connector in a workflow to determine if the initiator belongs to a Role or Group, return true else false. Has anyone attempted this and willing to share the java code.


Thanks in advance

1 reply

1-Visitor
October 12, 2011
The following expressions may be helpful. These was used in the
promotion workflow to determine if the creator was part of the
"Configuration Manager" group. You can probably clean this up somewhat
but it should get your started.



Expression Robot



wt.org.WTOrganization wtorg =
wt.org.WTOrganization.newWTOrganization("MyOrganization");
wt.org.DirectoryContextProvider directoryContextProvider =
(wt.org.DirectoryContextProvider) wtorg;
wt.maturity.PromotionNotice pn =
(wt.maturity.PromotionNotice)primaryBusinessObject;
String creatorUser = pn.getCreatorName().toString();

java.util.Enumeration windchillGroups =
wt.org.OrganizationServicesHelper.manager.findLikeGroups("Configuration
Managers", directoryContextProvider);
while (windchillGroups.hasMoreElements()) {
wt.org.WTGroup wtgroup = (wt.org.WTGroup)
windchillGroups.nextElement();
java.util.Enumeration usersEnum =wtgroup.members();
while(usersEnum.hasMoreElements()){
wt.org.WTUser user = (wt.org.WTUser)usersEnum.nextElement();
String groupUser = user.getName();
if (groupUser == creatorUser)
{
isAdmin = "True";
}
}
}



Conditional Expression



if (isAdmin.equals("True"))
{
result = "isAdmin";
}
else
{
result = "notAdmin";
}



Hope this helps,

Dax