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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to stop a User selecting himself as an Approver in Promotion Request?

AmarKarthi_Aras
2-Explorer

How to stop a User selecting himself as an Approver in Promotion Request?

We need to configure a business process in which we are using the Default "Promotion Request Approval Process" that is available OOTB. We want to stop the users from selecting themselves as an Approver in the Promotion Process.

PTC Tech support said this isn't possible. But doesn't this kill the process by itself? When the process isn't fool proof to stop the user selecting himself as an approver what is the use of it then? Is this achievable through any configuration options?

Thanks in advance!

7 REPLIES 7

OOTB this isn't possible for some alternative customization see below thread

 

 

Re: Prevent user from selecting themselves approve... - PTC Community

 

Thanks

Shreyas

I have not tested the following, but it might be worth a try.

Get rid of the Approver role in the workflow activity.

Into that workflow activity, put in a role from the Context Team page.

Choose an individual (or group) to assign that role on the Context Team page.

Create a customized layout (through the use of a sub/soft-type) to remove the 'Approver' field.

If it works, then the Approver can never be chosen and it will always revert to the person/group assigned to that role on the Context Team page. Of course, this means less flexibility but sometimes that's worth it.

Easiest option would be to modify the workflow to include a Conditional check immediately after the Start to compare the Creator and the Approver, and then if true send a new user task to the Creator saying "Fix Invalid Participants" or something along those lines with a Set Up Participants tab selected so they pick someone new.

Hi Amar,

The form delegate class PromotionParticipantsFormDelegate is marked supported. If you want to provide an error you should extend com.ptc.windchill.enterprise.maturity.forms.delegates.PromotionParticipantsFormDelegate and should override the preprocess method and call getParticipantsToProcess method to validate that the current user is not selected as an approver.

Check the following code, I would make appropriate changes if I am using WTGroups , I have hard-coded the casting to WTUser:

@Override

  public FormResult preProcess(NmCommandBean commandBean, List<ObjectBean> objectBeans)

  throws WTException {

  // TODO Auto-generated method stub

  //getParticipantsToProcess(arg0)

  for (ObjectBean objectBean : objectBeans) {

  Object object = objectBean.getObject();

  if (object instanceof LifeCycleManaged) {

  HashMap mapp= (HashMap) getParticipantsToProcess(objectBean);

  Iterator it = mapp.entrySet().iterator();

  while (it.hasNext()) {

  Map.Entry pair = (Map.Entry)it.next();

  Iterator iter = ((Set)pair.getValue()).iterator();

  while (iter.hasNext()) {

  WTUser principal=(WTUser) iter.next();

  WTUser Sessionuser= (WTUser) SessionHelper.manager.getPrincipal();

  //System.out.println(principal+"--"+Sessionuser);

  /*

  * Note pair.getKey() will give you the role, you can execute the following only for a particular role

  *

  */

  if (principal.getName().equalsIgnoreCase(Sessionuser.getName())) {

  FormResult result;

  FeedbackMessage errors= new FeedbackMessage();

  errors.addMessage("You cannot select yourself as  "+ pair.getKey()+ " Please select any other user");

  result = new FormResult(FormProcessingStatus.FAILURE);

  result.addFeedbackMessage(errors);

  return result;

  }

  }

  }

  }

  }

  return super.preProcess(commandBean, objectBeans);

  }

OOTB, delegate is registered in Windchill\codebase\config\actions\PromotionRequest-actions.xml (I will prefer to do this in custom*Action file, refer customization guide for more details.)

<action name="workflowParticipantsStep" required="false" preloadWizardPage="false">

<description>Promote wizard promotion objects step</description>

       <command class="com.ptc.windchill.enterprise.maturity.forms.delegates.PromotionParticipantsFormDelegate" windowType="wizard_step"/>

      </action>

Regards,

Bhushan

mcelino
5-Regular Member
(To:BhushanNehe)

Thank You Bhushan you helped me very much.

Your answer is definitely the one...

Massimo

You can modify the existing Promotion Request Approval Process template to only display the approvers to the requestor in the 'Select Participants' screen.

Note: if you are concerned about modifying the OOTB templates, I suggest copying the template and creating your own version.

  • Open the template for editing (Utilities: Workflow Template Administration)
  • Edit the Promotion Request Approval Process
  • Click on the Approve Promotion Request node
  • Under Resource Pool tab, select Approver on the left drop down, remove the default Context Team and add the appropriate Approver roles/groups/teams

Save and check in the template

Hope this helps

Hi Amar,

we have done this through customizing the delegate class. Pretty similar to what Bhushan has explained.

Announcements


Top Tags