- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 05:49 AM
Hi,
I need to create user criteria based on Title. I used below script and it work fine for one Title however I have to use multiple Title and when I use multiple Title it doesn't work.
var userCheck = new GlideRecord("sys_user");
userCheck.addQuery("sys_id", gs.getUserID());
userCheck.query();
if (userCheck.next()) {
if (userCheck.title.indexOf('Customer Service Supervisor'||'Triage Supervisor')>-1)
answer = true;
else
answer = false;
}
Regards,
Jitendra Singh
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 06:44 AM
Hi Jitendra
Try this which seems to work for me (remember to clear browser session after updating the User Criteria):
checkCondition();
function checkCondition() {
var titles = ['Customer Service Supervisor','Triage Supervisor'];
var title = gs.getUser().getRecord().getValue('title');
for (var i=0; i < titles.length; i++){
if (title.toLowerCase() == titles[i].toLowerCase()) {
return true;
}
}
return false;
}
- Matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2025 04:11 AM
As of today, above method is not suggested.
You need to use user_id instead of gs.getUser() method, as it can create cache conflicts.
See KB0780775 for reference: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0780775
Regards,
Simone