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

Tomas Linde
Tera Expert

Hello everyone,
I have created this User Criteria to prevent access to all users who contain the keyword "Manager" in their first and/or last name, it works for me but I also need it to prevent me from selecting this type of user in a variable of type reference to the "sys_user" table of my catalog item, any ideas (it's my first time using User Criteria).
Greetings and thank you.

 

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;
}
5 REPLIES 5

I see...in that case, I'd recommend trying the other approach ->> replace the field on the catalog item with the "request for" type instead of a reference field to sys_user.