<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: About the role assignment code in Expression in Windchill Customization</title>
    <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851075#M2215</link>
    <description>&lt;P&gt;Workflow:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="akış.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/74762i9DAC5B63BB12218C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="akış.png" alt="akış.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Open Process Manager:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smcvr_0-1674460296916.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/74765i45EA5CFDAC6533BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smcvr_0-1674460296916.png" alt="smcvr_0-1674460296916.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;wt.org.DirectoryContextProvider contextProvider = wt.inf.container.WTContainerHelper.service.getExchangeContainer().getContextProvider();
     wt.org.WTGroup wgroup = wt.org.OrganizationServicesHelper.manager.getGroup(katilimci, contextProvider);
	 wt.query.QuerySpec qs = new wt.query.QuerySpec(wt.org.WTGroup.class);
     wt.query.SearchCondition sc = new wt.query.SearchCondition(wt.org.WTGroup.class, wt.org.WTGroup.NAME, wt.query.SearchCondition.EQUAL, katilimci);
     qs.appendWhere(sc, new int[] { 0 });

  for(wt.fc.QueryResult queryResult = wt.fc.PersistenceHelper.manager.find(qs); queryResult != null &amp;amp;&amp;amp; queryResult.hasMoreElements();)
     wgroup = (wt.org.WTGroup)queryResult.nextElement();
     
     java.util.ArrayList&amp;lt;WTUser&amp;gt; members = new java.util.ArrayList&amp;lt;WTUser&amp;gt;();
     java.util.Enumeration&amp;lt;wt.org.WTPrincipal&amp;gt; member = wgroup.members();

  while (member.hasMoreElements()) {
     wt.org.WTPrincipal principal = (wt.org.WTPrincipal) member.nextElement();
  if (principal instanceof WTUser){
     members.add((WTUser) principal);}
   }
    wt.change2.ChangeIssue ci =( wt.change2.ChangeIssue)primaryBusinessObject;
    wt.team.Team team = wt.team.TeamHelper.service.getTeam(ci);
	 wt.org.WTPrincipal wtprincial = members.get(0);
        wt.project.Role role = wt.project.Role.toRole("Submitter");

      if (role == null) { 
      team.addPrincipal(role, wtprincial);  
      team.addPrincipal(wt.project.Role.toRole("Submitter"), wtprincial); 
      wt.fc.PersistenceHelper.manager.save(team);
      team = (wt.team.Team)PersistenceHelper.manager.refresh(team);  
     }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the variable "kilimci" as a string from another expression. I changed the code as you said, it does not show an error in the code. There is no error in open process manager, but when it comes to the activity, it shows as completed and does not send me a task.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2023 07:55:10 GMT</pubDate>
    <dc:creator>smcvr</dc:creator>
    <dc:date>2023-01-23T07:55:10Z</dc:date>
    <item>
      <title>About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850335#M2208</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;wt.org.DirectoryContextProvider contextProvider = wt.inf.container.WTContainerHelper.service.getExchangeContainer().getContextProvider();
      wt.org.WTGroup wgroup = wt.org.OrganizationServicesHelper.manager.getGroup("YONETICI", contextProvider);
	 wt.query.QuerySpec qs = null;
      qs = new wt.query.QuerySpec(wt.org.WTGroup.class);
      wt.query.SearchCondition sc = new wt.query.SearchCondition(wt.org.WTGroup.class, wt.org.WTGroup.NAME, wt.query.SearchCondition.EQUAL, "YONETICI");
      qs.appendWhere(sc, new int[] { 0 });

  for(wt.fc.QueryResult queryResult = wt.fc.PersistenceHelper.manager.find(qs); queryResult != null &amp;amp;&amp;amp; queryResult.hasMoreElements();)
     wgroup = (wt.org.WTGroup)queryResult.nextElement();

     java.util.ArrayList&amp;lt;WTUser&amp;gt; members = new java.util.ArrayList&amp;lt;WTUser&amp;gt;();
     java.util.Enumeration&amp;lt;wt.org.WTPrincipal&amp;gt; member = wgroup.members();

  while (member.hasMoreElements()) {
     wt.org.WTPrincipal principal = (wt.org.WTPrincipal) member.nextElement();
  if (principal instanceof WTUser){
     members.add((WTUser) principal);}
   }

     wt.team.Team team = new wt.team.Team();
	 team.setName("My Team");
	 wt.org.WTPrincipal wtprincial = members.get(0);
        wt.project.Role role = wt.project.Role.toRole("Submitter");

      if (role == null) { 
      team.addPrincipal(role, wtprincial);  
      team.addPrincipal(wt.project.Role.toRole("Submitter"), wtprincial); 
      wt.fc.PersistenceHelper.manager.save(team);
      team = (wt.team.Team)PersistenceHelper.manager.refresh(team);  
     }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code above does not give an error, but when I run the flow, it does not return a user to me. There is a registered user in the "YONETICI" group, I want to assign that user to the Submitter role and send a task, but the task does not go to the user.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 14:03:22 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850335#M2208</guid>
      <dc:creator>smcvr</dc:creator>
      <dc:date>2024-03-15T14:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850365#M2209</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/651715"&gt;@smcvr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show screen shot of workflow that others can imagine where the code and task are run&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check BacgroudnMethodServer.log if there is any error from WF&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Last point the method&amp;nbsp;&lt;STRONG&gt;Role.toRole(&lt;/STRONG&gt;&lt;SPAN&gt;"NAMEOFROLE"&lt;/SPAN&gt;&lt;SPAN&gt;) has to use internal name of the ROLE so &lt;STRONG&gt;Submitter&lt;/STRONG&gt; I guess is &lt;STRONG&gt;SUBMITTER&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PetrH&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 13:59:00 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850365#M2209</guid>
      <dc:creator>HelesicPetr</dc:creator>
      <dc:date>2023-01-19T13:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850480#M2210</link>
      <description>&lt;P&gt;Looks like you are creating a new team, not modifying the existing team of the workflow or PBO.&amp;nbsp; There is no tying the team you created to the workflow. Did I miss something?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 19:16:21 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850480#M2210</guid>
      <dc:creator>avillanueva</dc:creator>
      <dc:date>2023-01-19T19:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850576#M2211</link>
      <description>&lt;P&gt;how can i add to existing team?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 07:22:25 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850576#M2211</guid>
      <dc:creator>smcvr</dc:creator>
      <dc:date>2023-01-20T07:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850593#M2212</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/651715"&gt;@smcvr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Get the team from the object where the workflow is running on by following code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;wt.team.Team team = wt.team.TeamHelper.service.getTeam(ci); // CI is a object Change Issue, WTPart, ChangeRequest, PromotionRequest what ever. &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: 'Courier New'; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/27334"&gt;@avillanueva&lt;/a&gt;&amp;nbsp;good point with the new Team I didn't check the code so carefully &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PetrH&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 07:54:25 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850593#M2212</guid>
      <dc:creator>HelesicPetr</dc:creator>
      <dc:date>2023-01-20T07:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850606#M2213</link>
      <description>&lt;LI-CODE lang="markup"&gt;     wt.org.DirectoryContextProvider contextProvider = wt.inf.container.WTContainerHelper.service.getExchangeContainer().getContextProvider();
     wt.org.WTGroup wgroup = wt.org.OrganizationServicesHelper.manager.getGroup("YONETICI", contextProvider);
	 wt.query.QuerySpec qs = new wt.query.QuerySpec(wt.org.WTGroup.class);
     wt.query.SearchCondition sc = new wt.query.SearchCondition(wt.org.WTGroup.class, wt.org.WTGroup.NAME, wt.query.SearchCondition.EQUAL, "YONETICI");
     qs.appendWhere(sc, new int[] { 0 });

  for(wt.fc.QueryResult queryResult = wt.fc.PersistenceHelper.manager.find(qs); queryResult != null &amp;amp;&amp;amp; queryResult.hasMoreElements();)
     wgroup = (wt.org.WTGroup)queryResult.nextElement();
     
     java.util.ArrayList&amp;lt;WTUser&amp;gt; members = new java.util.ArrayList&amp;lt;WTUser&amp;gt;();
     java.util.Enumeration&amp;lt;wt.org.WTPrincipal&amp;gt; member = wgroup.members();

  while (member.hasMoreElements()) {
     wt.org.WTPrincipal principal = (wt.org.WTPrincipal) member.nextElement();
  if (principal instanceof WTUser){
     members.add((WTUser) principal);}
   }

     wt.workflow.work.WfAssignedActivity act = (wt.workflow.work.WfAssignedActivity) self.getObject();
	 wt.workflow.engine.WfProcess pro = (wt.workflow.engine.WfProcess) act.getParentProcess();
	 wt.team.Team team = wt.team.TeamHelper.service.getTeam(pro);
	 wt.org.WTPrincipal wtprincial = members.get(0);
        wt.project.Role role = wt.project.Role.toRole("Submitter");

      if (role == null) { 
      team.addPrincipal(role, wtprincial);  
      team.addPrincipal(wt.project.Role.toRole("Submitter"), wtprincial); 
      wt.fc.PersistenceHelper.manager.save(team);
      team = (wt.team.Team)PersistenceHelper.manager.refresh(team);  
     }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I edited the code, I don't get an error in the expression, but when I run the workflow, it stops in the expression where the code is written and I get the following error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;wt.util.WTException: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity
Nested exception is: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity
Nested exception is: wt.util.WTException: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity
Nested exception is: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity
wt.workflow.engine.FailedExpressionException: wt.util.WTException: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity
Nested exception is: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity
Nested exception is: wt.util.WTException: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity
Nested exception is: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity
at wt.workflow.expr.WfExpression111135098.executemethod_1(WfExpression111135098.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at wt.workflow.definer.WfExpression.invokeByReflection(WfExpression.java:1465)
at wt.workflow.definer.WfExpression.executeTransition(WfExpression.java:1408)
at wt.workflow.definer.WfExpression.execute(WfExpression.java:477)
at wt.workflow.robots.WfExpressionRobot.run(WfExpressionRobot.java:162)
at wt.workflow.engine.StandardWfEngineService.runRobot(StandardWfEngineService.java:1187)
at sun.reflect.GeneratedMethodAccessor942.invoke(Unk&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 09:17:32 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850606#M2213</guid>
      <dc:creator>smcvr</dc:creator>
      <dc:date>2023-01-20T09:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850614#M2214</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/651715"&gt;@smcvr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error tells you that object&amp;nbsp;WfProcess can not be used in variable type&amp;nbsp;WfAssignedActivity&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you need to work correctly with WFProcess,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if the code is run by robot directly in &lt;STRONG&gt;workflow&lt;/STRONG&gt; then&amp;nbsp;self.getObject(); is the object type &lt;STRONG&gt;WfProcess&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;if the code is run from workflow &lt;STRONG&gt;activity&lt;/STRONG&gt; then&amp;nbsp;self.getObject(); is the object type&amp;nbsp;&lt;STRONG&gt;WfAssignedActivity&lt;/STRONG&gt;&amp;nbsp;and you need to get the parent object that is&amp;nbsp;WfProcess&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: you need to get the team from primaryBussinessObject not from workflow.&lt;/P&gt;
&lt;P&gt;PS2: for better imagination &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&amp;nbsp;&lt;SPAN&gt;Show screen shot of workflow that others can imagine where the code and task are run&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;PetrH&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 09:29:09 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/850614#M2214</guid>
      <dc:creator>HelesicPetr</dc:creator>
      <dc:date>2023-01-20T09:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851075#M2215</link>
      <description>&lt;P&gt;Workflow:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="akış.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/74762i9DAC5B63BB12218C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="akış.png" alt="akış.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Open Process Manager:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smcvr_0-1674460296916.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/74765i45EA5CFDAC6533BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smcvr_0-1674460296916.png" alt="smcvr_0-1674460296916.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;wt.org.DirectoryContextProvider contextProvider = wt.inf.container.WTContainerHelper.service.getExchangeContainer().getContextProvider();
     wt.org.WTGroup wgroup = wt.org.OrganizationServicesHelper.manager.getGroup(katilimci, contextProvider);
	 wt.query.QuerySpec qs = new wt.query.QuerySpec(wt.org.WTGroup.class);
     wt.query.SearchCondition sc = new wt.query.SearchCondition(wt.org.WTGroup.class, wt.org.WTGroup.NAME, wt.query.SearchCondition.EQUAL, katilimci);
     qs.appendWhere(sc, new int[] { 0 });

  for(wt.fc.QueryResult queryResult = wt.fc.PersistenceHelper.manager.find(qs); queryResult != null &amp;amp;&amp;amp; queryResult.hasMoreElements();)
     wgroup = (wt.org.WTGroup)queryResult.nextElement();
     
     java.util.ArrayList&amp;lt;WTUser&amp;gt; members = new java.util.ArrayList&amp;lt;WTUser&amp;gt;();
     java.util.Enumeration&amp;lt;wt.org.WTPrincipal&amp;gt; member = wgroup.members();

  while (member.hasMoreElements()) {
     wt.org.WTPrincipal principal = (wt.org.WTPrincipal) member.nextElement();
  if (principal instanceof WTUser){
     members.add((WTUser) principal);}
   }
    wt.change2.ChangeIssue ci =( wt.change2.ChangeIssue)primaryBusinessObject;
    wt.team.Team team = wt.team.TeamHelper.service.getTeam(ci);
	 wt.org.WTPrincipal wtprincial = members.get(0);
        wt.project.Role role = wt.project.Role.toRole("Submitter");

      if (role == null) { 
      team.addPrincipal(role, wtprincial);  
      team.addPrincipal(wt.project.Role.toRole("Submitter"), wtprincial); 
      wt.fc.PersistenceHelper.manager.save(team);
      team = (wt.team.Team)PersistenceHelper.manager.refresh(team);  
     }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the variable "kilimci" as a string from another expression. I changed the code as you said, it does not show an error in the code. There is no error in open process manager, but when it comes to the activity, it shows as completed and does not send me a task.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 07:55:10 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851075#M2215</guid>
      <dc:creator>smcvr</dc:creator>
      <dc:date>2023-01-23T07:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851088#M2216</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/651715"&gt;@smcvr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should use refresh to the saved team so&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;team  = (wt.team.Team)wt.fc.PersistenceHelper.manager.save(team);
team = (wt.team.Team)PersistenceHelper.manager.refresh(team);  &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would check an task action if the role submitter is used in the task.&lt;/P&gt;
&lt;P&gt;I guess there can be different role.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also check the Member Participant list in a detail page of the primary object at a process tab&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HelesicPetr_0-1674462294986.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/74772i3BABFFB4E7A26E23/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HelesicPetr_0-1674462294986.png" alt="HelesicPetr_0-1674462294986.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PetrH&lt;/P&gt;
&lt;P&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 08:25:11 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851088#M2216</guid>
      <dc:creator>HelesicPetr</dc:creator>
      <dc:date>2023-01-23T08:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851092#M2217</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/651715"&gt;@smcvr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I checked my examples of the assigning the participants to roles so, try it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;wt.org.WTPrincipal principal = ((wt.org.WTPrincipalReference)principals.nextElement()).getPrincipal();	
wt.team.TeamHelper.service.addRolePrincipalMap(wt.project.Role.toRole("ASSIGNEE"), principal, teamActivity);  
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PetrH&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 08:32:33 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851092#M2217</guid>
      <dc:creator>HelesicPetr</dc:creator>
      <dc:date>2023-01-23T08:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851163#M2218</link>
      <description>&lt;P&gt;I did not understand what you said. there is no error in my code but it doesn't work. Thanks for be interested.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 13:20:18 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851163#M2218</guid>
      <dc:creator>smcvr</dc:creator>
      <dc:date>2023-01-23T13:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851164#M2219</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/651715"&gt;@smcvr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I asked you to check if your role has been updated by your participant.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to go step by step to show you why it does not work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally I said that you should use different function to set the participant to a role&lt;/P&gt;
&lt;P&gt;So try it.&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;wt.team.TeamHelper.service.addRolePrincipalMap(wt.project.Role.toRole("ASSIGNEE"), principal, teamActivity);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PetrH&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 13:26:27 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851164#M2219</guid>
      <dc:creator>HelesicPetr</dc:creator>
      <dc:date>2023-01-23T13:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851505#M2220</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smcvr_0-1674565040081.png" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/74931i99F12DDDEA1048FE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smcvr_0-1674565040081.png" alt="smcvr_0-1674565040081.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;wt.org.DirectoryContextProvider contextProvider = wt.inf.container.WTContainerHelper.service.getExchangeContainer().getContextProvider();
     wt.org.WTGroup wgroup = wt.org.OrganizationServicesHelper.manager.getGroup(katilimci, contextProvider);
	 wt.query.QuerySpec qs = new wt.query.QuerySpec(wt.org.WTGroup.class);
     wt.query.SearchCondition sc = new wt.query.SearchCondition(wt.org.WTGroup.class, wt.org.WTGroup.NAME, wt.query.SearchCondition.EQUAL, katilimci);
     qs.appendWhere(sc, new int[] { 0 });

  for(wt.fc.QueryResult queryResult = wt.fc.PersistenceHelper.manager.find(qs); queryResult != null &amp;amp;&amp;amp; queryResult.hasMoreElements();)
     wgroup = (wt.org.WTGroup)queryResult.nextElement();
     
     java.util.ArrayList&amp;lt;WTUser&amp;gt; members = new java.util.ArrayList&amp;lt;WTUser&amp;gt;();
     java.util.Enumeration&amp;lt;wt.org.WTPrincipal&amp;gt; member = wgroup.members();
  while (member.hasMoreElements()) {
     wt.org.WTPrincipal principal = (wt.org.WTPrincipal) member.nextElement();
	 		
  if (principal instanceof WTUser){
     members.add((WTUser) principal);}
   }
    wt.change2.ChangeIssue ci =( wt.change2.ChangeIssue)primaryBusinessObject;
    team = wt.team.TeamHelper.service.getTeam(ci);
	  wtprincial = members.get(0);
      role = wt.project.Role.toRole("ASSIGNEE");
    &lt;/LI-CODE&gt;&lt;P&gt;The above part works. I pull the user from the group and assign it to the wtprincial variable but I can't pass it to the role variable&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  if (role == null) {   
	 
      team.addPrincipal(role, wtprincial);  
	  wt.team.TeamHelper.service.addRolePrincipalMap(wt.project.Role.toRole("ASSIGNEE"), wtprincial, team);
      wt.fc.PersistenceHelper.manager.save(team);
     }
	 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 13:03:29 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851505#M2220</guid>
      <dc:creator>smcvr</dc:creator>
      <dc:date>2023-01-24T13:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851512#M2221</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/651715"&gt;@smcvr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not use a Variable use a Role&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HelesicPetr_0-1674566080790.png" style="width: 578px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/74932iC2C50138A4BCAC0C/image-dimensions/578x274?v=v2" width="578" height="274" role="button" title="HelesicPetr_0-1674566080790.png" alt="HelesicPetr_0-1674566080790.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does condition&amp;nbsp;&lt;STRONG&gt;if (role == null)&amp;nbsp;&lt;/STRONG&gt;means? if role exists it is never null.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PetrH&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 13:18:27 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851512#M2221</guid>
      <dc:creator>HelesicPetr</dc:creator>
      <dc:date>2023-01-24T13:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851524#M2222</link>
      <description>&lt;P&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/651715"&gt;@smcvr&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additional information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you use a Variable to assign a participant do not use wt.project.Role. It can not work this way, Role as a object do not contains members it is just Enumeration. Use WTParticipant type or WTUser.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also the variable can not be used as you use it with&amp;nbsp;wt.team.TeamHelper.service.addRolePrincipalMap.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The assignee is a role from a team connected with primaryBusinessObject not with Variable of the task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PetrH&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 14:32:36 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851524#M2222</guid>
      <dc:creator>HelesicPetr</dc:creator>
      <dc:date>2023-01-24T14:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: About the role assignment code in Expression</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851652#M2223</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/241117"&gt;@HelesicPetr&lt;/a&gt;&amp;nbsp;;&lt;/P&gt;&lt;P&gt;Thank you for the help. Workflow is running.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 09:06:43 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/About-the-role-assignment-code-in-Expression/m-p/851652#M2223</guid>
      <dc:creator>smcvr</dc:creator>
      <dc:date>2023-01-25T09:06:43Z</dc:date>
    </item>
  </channel>
</rss>

