Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

@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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

Thank you the script worked😊

Vaishnavi Lathk
Mega Sage
Mega Sage

Hello,

Did you check any does that user have ITIL role?

 

Regards,

Vaishnavi Lathkar

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