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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

workflow expression code error

smcvr
15-Moonstone

workflow expression code error

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

ACCEPTED SOLUTION

Accepted Solutions
HelesicPetr
22-Sapphire I
(To:smcvr)

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

View solution in original post

5 REPLIES 5
smcvr
15-Moonstone
(To:smcvr)

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

HelesicPetr
22-Sapphire I
(To:smcvr)

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 

smcvr
15-Moonstone
(To:HelesicPetr)

hi HelesicPetr
I am using version 12.0.4

HelesicPetr
22-Sapphire I
(To:smcvr)

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

smcvr
15-Moonstone
(To:HelesicPetr)

@HelesicPetr  Thanks.

Announcements


Top Tags