Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
hello, I have a workflow and in this workflow, the flow goes to different parts according to the values in the global enumeration in the attribute in a particular layout. In fact, I make users choose a section, and as a result, the flow progresses according to the selected section.
The problem is that I do this for each partition and I have 30 partitions in total. which means task and etc required for 30 sections.
How should I use something here so that the participant I selected directly finds the role or group in the enumeration?
Can you explain better? I loathe these fanned workflows for this reason. What happens in each sub-workflow block you show there?
Hello avillanueva,
sorry for my late reply,
there is only task inside the blocks. I'm sending a task to a user whose name I just specified. For example "tanker silo manager".
Maybe it would be cleaner the write an expression to add the group into the role, instead of all those blocks.
// find the team for this wf
wt.team.Team team = (wt.team.Team) ((wt.workflow.engine.WfProcess) self.getObject()).getTeamId().getObject();
wt.org.WTPrincipal wtprincipaltoadd = //the principal to add into the role
// remove everyone/anyone else from the role
java.util.Enumeration principals = team.getPrincipalTarget(wt.project.Role.toRole("SUBMITTER")); // the role KEY = SUBMMITER
while(principals.hasMoreElements())
{
wt.org.WTPrincipalReference principalRef = (wt.org.WTPrincipalReference)principals.nextElement();
wt.org.WTPrincipal wtprincipal = principalRef.getPrincipal();
wt.team.TeamHelper.service.deleteRolePrincipalMap(wt.project.Role.toRole("SUBMITTER"), wtprincipal, team );
}
// add principal to the SUBMITTER role
wt.team.TeamHelper.service.addRolePrincipalMap(wt.project.Role.toRole("SUBMITTER"), wtprincipaltoadd, team);
What does submitter do?
I can direct the flow according to the section selections entered by the users, but when I want to send the tasks to the necessary people, I have to choose a separate participant for each section, which intensifies the flow. Is there any way I can do this problem in a single domain?
I can select participants according to the section selected below, but I need to create another one for a different section.
In my case the Submitter is the Role name for the user who submitted something for a review.
You can assign the task to always the same Role, the expression I shared above shows how to add a principal into the Role.
I examined the code you gave and tried to assign the principal assignment part with the username directly, but it gave me this error
wt.team.Team team = (wt.team.Team) ((wt.workflow.engine.WfProcess) self.getObject()).getTeamId().getObject();
wt.org.WTPrincipal principal = wt.org.OrganizationHelper.getPrincipal("userName");
java.util.Enumeration principals = team.getPrincipalTarget(wt.project.Role.toRole("Submitter"));
while(principals.hasMoreElements())
{
wt.org.WTPrincipalReference principalRef = (wt.org.WTPrincipalReference)principals.nextElement();
wt.org.WTPrincipal wtprincipal = principalRef.getPrincipal();
wt.team.TeamHelper.service.deleteRolePrincipalMap(wt.project.Role.toRole("Submitter"), wtprincipal, team );
}
wt.team.TeamHelper.service.addRolePrincipalMap(wt.project.Role.toRole("Submitter"), principal, team);
--------------------------------------------------------------------------------------------------
WfExpression_11.java:75: error: cannot find symbol
wt.org.WTPrincipal principal = wt.org.OrganizationHelper.getPrincipal("sumeyye.cevahir");
^
symbol: class OrganizationHelper
location: package wt.org
Note: WfExpression_11.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
If you wanted to assign a particular user to the submitter role with code, although I can't really see why you'd ever want to do that.
wt.org.DirectoryContextProvider dcp = wt.org.OrganizationServicesHelper.manager.newDirectoryContextProvider((String[])null,(String[])null);
String email = "tom@ptc.com";
java.util.Enumeration principalsusers = wt.org.OrganizationServicesHelper.manager.findLikeUsers ( wt.org.WTUser.E_MAIL, email, dcp );
if (principalsusers != null && principalsusers.hasMoreElements () ){
wt.org.WTPrincipal wtprincipaltoadd = (wt.org.WTUser)principalsusers.nextElement();
wt.team.TeamHelper.service.addRolePrincipalMap(wt.project.Role.toRole("SUBMITTER"), wtprincipaltoadd, team);
}
Would need to add handling of the error when the user is not found inevitably.