- 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 02:46 AM
first define who is public user and which is end user
based on that you can modify the script
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 10:46 PM
@Ankur Bawiskar Hi end user is a person with no roles but still fits into the above user criteria I am bit confused why it is acting weird for end users.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 10:54 PM
share your entire script along with screenshots
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:01 PM - edited 07-05-2023 11:09 PM
@Ankur Bawiskar here it is
checkCondition();
function checkCondition() {
var user = new GlideRecord('sys_user');
user.addEncodedQuery('active=true^emailENDSWITHxxxx.com');
user.query();
}