Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

User Criteria Catalog Item Alert

Tomas Linde
Tera Expert

Hello everyone,
I have created this User Criteria to prevent access to all users that contain the keyword "Manager" in their firstname and/or their lasname, in addition to this I need this message to be displayed when I select a user "Manager" in a variable of the Catalog Item of type references to the "sys_user" table through this same User Criteria. The photo is an example of a User Criteria box that displays the message in case users who do not belong to a specific location are selected. Any ideas ?
Greetings and thank you.Captura de pantalla 2024-02-26 a las 21.37.46.png

2 REPLIES 2

Saloni Suthar
Giga Sage
Giga Sage

Hi @Tomas Linde ,

Can you please share screenshots of your user criteria here?


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

function evaluateControl() {

  var user = new GlideRecord('sys_user');
  user.get(gs.getUserID());

  var firstName = user.getValue('first_name');
  var lastName = user.getValue('last_name');

  firstName = firstName.toLowerCase();
  lastName = lastName.toLowerCase();

  var containsManager = firstName.indexOf('manager') !== -1 || lastName.indexOf('manager') !== -1;

  if (containsManager) {
    return false;
  }

  return true;
}