We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Advanced User criteria

Midilesh
Tera Contributor

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();
}

 

1 ACCEPTED SOLUTION

@Midilesh 

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();
}
Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron

@Midilesh 

first define who is public user and which is end user

based on that you can modify the script

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Midilesh
Tera Contributor

@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. 

@Midilesh 

share your entire script along with screenshots

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  here it is

checkCondition();

function checkCondition() {
var user = new GlideRecord('sys_user');
user.addEncodedQuery('active=true^emailENDSWITHxxxx.com');
user.query();
}

 

User criteria.png