Skip to main content
15-Moonstone
January 16, 2023
Solved

workflow expression code error

  • January 16, 2023
  • 1 reply
  • 2708 views

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

Best answer by HelesicPetr

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();

 

HelesicPetr_0-1673943361786.png

 

PetrH

1 reply

smcvr15-MoonstoneAuthor
15-Moonstone
January 16, 2023

There is no wt.fc.collections library in windchill classes either.

HelesicPetr
22-Sapphire II
22-Sapphire II
January 16, 2023

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 

smcvr15-MoonstoneAuthor
15-Moonstone
January 16, 2023

hi HelesicPetr
I am using version 12.0.4