Skip to main content
1-Visitor
August 6, 2015
Question

Prevent user from selecting themselves approver?

  • August 6, 2015
  • 2 replies
  • 2299 views

Specifically during a promotion request, I'm trying to create an expression robot to remove the creator from the list of approvers, although, limiting the user during creation wizard of the promotion request would be the most helpful. Any suggestions? I'm very new to Windchill Admin so if this is a simple question, I apologize.

2 replies

1-Visitor
August 6, 2015
16-Pearl
September 1, 2015

Hi Paul,

Alternatively you can also try below code snippet in Approve Promotion Request's Complete Transition. This will check if current logged in (session) user is a Promotion Notice creator:

wt.org.WTUser currentUser = (wt.org.WTUser)wt.session.SessionHelper.manager.getPrincipal();

wt.workflow.engine.WfProcess wfprocess = ((wt.workflow.work.WfAssignedActivity)self.getObject()).getParentProcess();

wt.org.WTPrincipalReference creatorReference = wfprocess.getCreator();

wt.org.WTPrincipal wfCreator = ((wt.org.WTPrincipalReference)creatorReference).getPrincipal();

if((currentUser.toString()).equals(wfCreator.toString())){

throw new wt.util.WTException ( "ERROR: You cannot APPROVE your own promotion request.\nPlease reassign the task or ask Windchill Admins for help" );

}


I hope this helps you.


Regards,

Shirish

1-Visitor
January 20, 2016

Shirishkumar Morkhade‌ - does the exception message appear in the dialog for the user or does the exception only appear in the logs?  If it does, then great because I have previously used a downstream conditional node to loop back if criteria is not met.  In doing this I need to turn Task Notification off and have separate Notification Robots for new and returned Tasks.  My approach is less than optimal from a User perspective but it was the only way I could get the messaging to the User.  I did make Tech Support calls about how to control the message in the dialog that appears when a Transition condition is false was told it is not possible.  F

Also - I don't see anything that would return false and restrict the completion of the Transition.