One of the other ways is to do this from Java code using custom delegate, the OOTB delegate is marked supported for customization.
e.g.
public class CustomPromotionParticipantsFormDelegate extends PromotionParticipantsFormDelegate {
@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);
}
}