User Criteria

levino
Giga Guru

hi there

 

please can you advise if my user criteria script is ok, for some reason it always evaluates to false, even if the condition is met

 

 

Thanks

Levino

checkCondition(); 

function checkCondition(){
	var gra = new GlideRecord('sys_user');
	gra.addQuery('sys_id', gs.getUserID());
	gra.addEncodedQuery('manager=658db0e5db141b00a56336db7c961947^ORmanager=347451691bd3a990f1bebaeccc4bcb55^ORtitleSTARTSWITHCHAPTER^ORtitleSTARTSWITHDCL^ORtitleSTARTSWITHDOMAIN CHAPTER^ORsys_id=c61204c31b85111055f2baeccc4bcb82'); 
	gra.query();
	if (gra.next())
		return true;
	else
		return false;
}
9 REPLIES 9

Astik Thombare
Tera Sage

Hi @levino ,

 

Could you please elaborate it more what query you have given in Encoded Query ?

 

Thanks,
Astik

user manager  as per the sys_id  or if the users title starts with chapter,  i have tried users which are part of that criteria but  it still evaluates to false

Hi @levino ,

 

You can check in the background script whether it is returning something or not. Please navigate to System Definition -> Scripts - Background, and by using different users, you can verify if it is returning records or not

and according make changes to script . check below script to be used in background script -

 

 

var gra = new GlideRecord('sys_user');
	gra.addQuery('sys_id', gs.getUserID()); // try with different user sys_id 
	gra.addEncodedQuery('manager=658db0e5db141b00a56336db7c961947^ORmanager=347451691bd3a990f1bebaeccc4bcb55^ORtitleSTARTSWITHCHAPTER^ORtitleSTARTSWITHDCL^ORtitleSTARTSWITHDOMAIN CHAPTER^ORsys_id=c61204c31b85111055f2baeccc4bcb82'); 
	gra.query();
	if (gra.next()){
		gs.print (true);
}
	else
{
		gs.print(false);
}

 

 

According to that you can make changes to script 

 

     If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.

 

                         By doing so you help other community members find resolved questions which may relate to an issue they're having

 

 

Thanks,

 

Astik

 

 

interesting when i run in background script the same user evaluates to true

 

user criteria diagnostis  is that the way to check i am presuming?