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

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

Windchill Workflow - How to Require Users Actually Setup Participants?

lhoogeveen
17-Peridot

Windchill Workflow - How to Require Users Actually Setup Participants?

Currently, I've setup a basic document approval workflow in Windchill where the first task is to submit the document for approval and 'set up participants' of who to approve. Is there a way require that users actually 'set up participants' into the various roles? The set up participants is on a separate tab and it's easy for users to click submit without assigning anyone to the roles. Using Windchill 11.0 M030.

 

Windchill Workflow - Require Set Up Participants 1.jpg

 

Windchill Workflow - Require Set Up Participants 2.jpg

5 REPLIES 5
James62
12-Amethyst
(To:lhoogeveen)

Run a custom server side Java API code when the Complete Task button is clicked to fetch and validate the team object that is linked to the promotion request object.

 

How to run Java code on the Complete Task event is roughly explained here: https://community.ptc.com/t5/Windchill/Workflow-make-comments-mandatory-in-an-activity/td-p/4546

I'm not responsible for this code, but use it in my Change Activity process.  You will have to replace <ROLE NAME> with the actual name of the role.  I believe it is the Key name that you have to use, but am not positive right now.  You will need to add it to the transitions portion.  But be careful what transition you put it in.  If you have multiple transitions like Other, MGR, Cancel, you will need to put it for the transition that you are needing to make sure. You can put it under Complete, but that will force you to always have something in there even if you are canceling the routing.  You will just have to test.

 

	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 t = wt.team.TeamHelper.service.getTeam(pro);
	java.util.Map members = t.getRolePrincipalMap();
	java.util.Set keys = members.keySet();
	java.util.Iterator itr = keys.iterator();
	while (itr.hasNext()) {
		wt.project.Role role = (wt.project.Role) itr.next();
		System.out.println("Role-=-=-=" + role);
		if (role.toString().equalsIgnoreCase("<ROLE NAME>")) {
			java.util.ArrayList users = (java.util.ArrayList) members.get(role);
		//If there is no user in <ROLE NAME> role throw exception
			if (users.isEmpty()) {
			throw new Exception("Select user for " + role.getDisplay());
			}
		}
	}

I just used the Key for the role that you find in enumcustomize for the new workflow that I am working on.

Works with role display name too, Windchill 12.

I created a product idea to easily require this in the Windchill Workflow Tasks: Windchill Workflow - Ability to Require that Users Actually Setup Participants 

Announcements

Top Tags