- 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
‎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
‎09-23-2020 07:39 AM
Hi Matt,
Its working for only one Title "Customer Service Supervisor".
Regards,
Jitendra Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2020 08:19 AM
I re-tested in my instance and it works fine for me.
Can you check there are no extra spaces in the "Triage Supervisor" User title, that the code is re-copied as I edited it once after posting, and when impersonating users ensure you try in a new incognito window.
- Matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2020 06:02 AM
My bad. It worked. Thanks a lot!