- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 01:15 AM
Hi Team,
I have used below script in Advanced user criteria for restricting KB articles for public users when I tried the same it is also restricting KB's for our End-users(no roles) as well .Please share your thoughts.
Advanced Script :
checkCondition();
function checkCondition() {
var user = new GlideRecord('sys_user');
user.addEncodedQuery('active=true^emailENDSWITHXXX.com');
user.query();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 11:22 PM
you are not checking anywhere in your script for logged in user?
update as this
answer = checkCondition();
function checkCondition() {
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', user_id);
user.addEncodedQuery('active=true^emailENDSWITHxxxx.com');
user.query();
return user.hasNext();
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 11:22 PM
you are not checking anywhere in your script for logged in user?
update as this
answer = checkCondition();
function checkCondition() {
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', user_id);
user.addEncodedQuery('active=true^emailENDSWITHxxxx.com');
user.query();
return user.hasNext();
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 11:42 PM
Thank you the script worked😊

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 10:58 PM
Hello,
Did you check any does that user have ITIL role?
Regards,
Vaishnavi Lathkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 11:05 PM
Hi Vaishnavi ,
I checked it .I am declaring users from sys_user table with pretty much simple logic but it is not working for end user(no roles).