- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 08:12 AM
I am trying to use an advanced script for User Criteria. On the wiki the only documentation says that the script field is "A script to define any additional criteria, and return true or false. This field is available only if Advanced is selected."
There is no example provided. I can't figure out how to reference the user record. For example, if I want to say all users who are active. How would I do this? I know the basic logic, but am unsure of how to reference the user record in the script.
Example logic:
if (currentUserRecord.active == true) {
return true;
} else {
return false;
}
Any help would be appreciated.
Thanks,
Tim
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 08:18 AM
take a look at this page http://www.servicenowguru.com/scripting/user-object-cheat-sheet/
gs.getUser().getRecord().getValue('active') == true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 02:03 PM
for those that can't make this a simple query like that.... in geneva you have to wrap the answer in a function like this.
answer();
function answer(){
var job = gs.getUser().getRecord().getValue('u_job_family');
if (job == "Human Resources"){return true;}
else{return false;}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2018 02:33 AM
Thank you for that, I had to go that road, since dot walking was not working for me:
I did this:
//Getting the data of the current user
var grUser = new GlideRecord("sys_user");
grUser.addQuery("sys_id", gs.getUserID());
grUser.query();
//getting the value of L1R
if(grUser.next()){
answer = grUser.getValue('u_l1r') == true;
}
Regards,
N.