Restrict "Requested By" User from Being Selected as Manual Approver on Change Form

Sriram34
Tera Contributor

Hi Team,

 

On the Change form, we have a Manual Approver field which is a List Collector. Currently, it is configured to allow selection of only active users who have the approver_user role.
 

We have an additional requirement to enhance this restriction:

  • The Requested By user (the person who is raising the change) should not be allowed to select themselves as a Manual Approver.

In other words, when a user raises a change request, they should be prevented from adding themselves in the Manual Approver field.

 

Could anyone suggest the best way to implement this restriction?

 

 

Sriram34_0-1780899461266.png

 

Thanks in advance

7 REPLIES 7

@Sriram34 

then use before insert/update BR and handle the check and stop user from saving

(function executeRule(current, previous /* null when async */) {

    if (!current.requested_by || !current.your_list_field) {
        return;
    }

    var requestedBy = current.requested_by.toString();
    var listValue = current.your_list_field.toString().split(',');

    if (listValue.indexOf(requestedBy) > -1) {
        gs.addErrorMessage('Requested By user cannot be present in the list.');
        current.setAbortAction(true);
    }

})(current, previous);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Sriram34 

 

Create a Before Insert/Update Business Rule:

 

if (!current.manual_approvals.nil()) {

var approvers = current.manual_approvals.toString().split(',');

if (approvers.indexOf(current.requested_by.toString()) > -1) {
gs.addErrorMessage('Requested By user cannot be selected as a Manual Approver.');
current.setAbortAction(true);
}
}

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.

Regards,

Bharat chavan

Hi @Sriram34 

 

1. Best choice is to create Before (insert/update)BR , to restrict all including Add me and email address. -> Read the selected values->if it contains requested_by ->Show error message with  current.setAbortAction(true);

 

Alternative , just fyi  ( if business  agrees) - it would applicable to all users:

  1. To remove the "Add Me" button that appears next to fields like watch_list:

    • Navigate to the System Dictionary of your requested_by field definition for your table
    • Add no_add_me=true to the Attributes field
  2. To prevent users from selecting requested_by by typing their email address:

    • On the same dictionary entry record, add no_email=true to the Attributes list

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti