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.

How to use "does not end with" in reference qualifier

Bharat23
Kilo Guru

I need to show a list of user records where user id does not end with -a

"does not end with" is not available as an operator in reference field qualifier. Any other ideas in which it can be achieved?

5 REPLIES 5

kristenankeny
Tera Guru

I'd suggest doing an advanced reference qualifier that calls a script include. Here is an example:



find_real_file.png




This is the "getApps" function in the "AccessRequestSI" script include (script include needs to be client callable). Your script will be simpler, with just one glide record query:


getApps: function(){


  var what = current.variables.access;


  var db = current.variables.database;


  var ids = ' ';


  if(what == 'application'){


  var a = new GlideRecord('cmdb_ci_appl');


  a.addQuery('sys_class_name','cmdb_ci_appl');


  a.addQuery('u_allow_access_requests',true);


  a.query();


  while(a.next()){


  if(ids.length > 0){


  ids += (','+a.sys_id);


  }


  else{


  ids = a.sys_id;


  }


  }


  }


  else if(db == ''){


  var all = new GlideRecord('cmdb_ci_appl');


  all.addQuery('sys_class_name','cmdb_ci_appl');


  all.query();


  while(all.next()){


  if(ids.length > 0){


  ids += (','+all.sys_id);


  }


  else{


  ids = all.sys_id;


  }


  }


  }


  else if(db != ''){


  var m2m = new GlideRecord('cmdb_rel_ci');


  m2m.addQuery('child',db);


  m2m.query();


  while(m2m.next()){


  if(m2m.parent.sys_class_name == 'cmdb_ci_appl' && m2m.parent.install_state != 7){


  if(ids.length > 0){


  ids += (','+m2m.parent.sys_id);


  }


  else{


  ids = m2m.parent.sys_id;


  }


  }


  }


  }


  return 'sys_idIN' + ids;


  },


This wont practically work because it will return like 50000 sys_ids. In Helsinki there are 2 new reference qualifiers as shown below but I am not able to find any documentation on them. May be these operators can do what I want.



find_real_file.png


Here is the link on how to create a regex


Regular Expressions - JavaScript | MDN


I'm looking for some sample on syntax that servicenow expects for regex. It doesn't work if I write it in standard way.



Regards


Bharat