Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hi Community!
i created a code to assign role in workflow but i am getting error and i couldn't fix it.
can you help me?
code:
wt.org.WTPrincipal wtPrincipal = null;
wt.team.Team team = (wt.team.Team) ((wt.workflow.engine.WfProcess) self.getObject()).getTeamId().getObject();
wt.org.WTGroup group = (wt.org.WTGroup) team.getPrincipalTarget(wt.project.Role.toRole("SUBMITTER")).nextElement();
wt.fc.collections.WTList members = group.getPrincipals();
while(members.hasMoreElements()) {
wtPrincipal = (wt.org.WTPrincipal)((wt.org.WTPrincipalReference) members.nextElement()).getObject();
if (wtPrincipal instanceof wt.org.WTUser) {
wt.org.WTUser wtUser = (wt.org.WTUser) wtPrincipal;
if (wtUser.getName().equals("YONETICI-TEST")) {
wt.team.TeamHelper.service.addRolePrincipalMap(wt.project.Role.toRole("SUBMITTER"), wtUser, team);
break;
}
}
}
error:
warning: Supported source version 'RELEASE_7' from annotation processor 'com.microsoft.azure.management.apigeneration.LangDefinitionProcessor' less than -source '1.8'
WfExpression_11.java:73: error: cannot find symbol
wt.fc.collections.WTList members = group.getPrincipals();
^
symbol: method getPrincipals()
location: variable group of type WTGroup
WfExpression_11.java:75: error: cannot find symbol
while(members.hasMoreElements()) {
^
symbol: method hasMoreElements()
location: variable members of type WTList
WfExpression_11.java:76: error: cannot find symbol
wtPrincipal = (wt.org.WTPrincipal)((wt.org.WTPrincipalReference) members.nextElement()).getObject();
^
symbol: method nextElement()
location: variable members of type WTList
Note: WfExpression_11.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
1 warning
Solved! Go to Solution.
Hi @smcvr
Your issue is the "group.getPrincipals();" the WTGroup do not contains method getPrincipals() so it can not work.
You need to use .members(); also you need to change WTList to Enumeration
example
java.util.Enumeration members = group.members();
PetrH
There is no wt.fc.collections library in windchill classes either.
Hi @smcvr
What Windchill version do you use?
Because the class should be in the codebase (In my Windchill 12.0.2 the class exists)
PetrH
hi HelesicPetr
I am using version 12.0.4
Hi @smcvr
Your issue is the "group.getPrincipals();" the WTGroup do not contains method getPrincipals() so it can not work.
You need to use .members(); also you need to change WTList to Enumeration
example
java.util.Enumeration members = group.members();
PetrH