User Criteria not generating log statements?

Jared Wason
Tera Guru

Hello,

 

I am working on a user criteria that will only allow users in certain departments to see a knowledge base setup just for that department. However I can't get the user criteria to work and I am not even seeing the log statements I have made show up. I have been impersonating a user in the department who should have access to the knowledge base then clicking into Knowledge, but I dont see the knowledge base and nothing shows up in the logs. Below is the user criteria I made, any ideas what I am doing wrong here or missing?

 

gs.info("!JW! Users In Health Department START");
checkCondition();

function checkCondition(){
	gs.info("!JW! Users In Health Department in function");
	var userDept = gs.getUser().getRecord().getValue('u_itd_customers');
	gs.info("!JW! Users In Health Department Dept=" + userDept);

	if(userDept == 'f89970180f85e10019169de692050e36' || userDept == 'd741344c0fec21002bc4f3f692050e64'){
		return true;
	}else{
		return false;
	}	
}

 

1 ACCEPTED SOLUTION

-O-
Kilo Patron
Kilo Patron

User Criteria are cached on login, so it will not be run all the time it is needed.
You can test User Criteria using module "User Criteria Diagnostics":

1.png

Note that you don't need to use scripting for this, you can configure the "Departments" list on the user criteria record.

 

What is NOT optional is the usage of gs.getUser() vs. global variable user_id.

One must use global variable user_id to get the current user, not gs.getUser().

In fact the same is stated in the default comments in field Script on a brand new User Criteria record:

2.png

 

View solution in original post

1 REPLY 1

-O-
Kilo Patron
Kilo Patron

User Criteria are cached on login, so it will not be run all the time it is needed.
You can test User Criteria using module "User Criteria Diagnostics":

1.png

Note that you don't need to use scripting for this, you can configure the "Departments" list on the user criteria record.

 

What is NOT optional is the usage of gs.getUser() vs. global variable user_id.

One must use global variable user_id to get the current user, not gs.getUser().

In fact the same is stated in the default comments in field Script on a brand new User Criteria record:

2.png