The CreatorCon Call for Content is officially open! Get started here.

Should Not Available For evaluate to true or false?

kim-lindgren
Kilo Sage

If I put a user criteria with a script under Not Available For, will users be restricted when it evaluates to true or when it evaluates to false?

 

It might seem self-evident that the restriction happens when the script evaluates to true, but my instance is seemingly behaving the opposite way in one case, so I thought I'd ask for an authoritative answer.

 

Many thanks,

Kim

1 ACCEPTED SOLUTION

Hi @kim-lindgren,

 

Here's how I've just confirmed that 'answer = true;' does indeed block access - see the below screenshot.

Essentially, strip back the logic to confirm.

I added this User Criteria to a standard Catalog Item and added this under the 'Not Available For' against an item. I checked that when set to true, the user could not see the item. When set to false, the user could see the item. 

As an FYI, whilst in the script itself there is the below statement, I did have to clear the cache to confirm as I too was getting indifferent results until I cleared the cache and also logged out and logged back in.

I did say they were 'fun' didn't I. 

"Scripted User Criteria is not cached, and evaluated everytime, so performance is dependent on the script."

 

Also, as per the guidance, remove the statement: !gs.getUser().isMemberOf("GROUP");

You're going to have to user the 'user_name' object (which is the sys_id of the user which the evaluation is against.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 
 
Screenshot 2024-02-07 at 15.42.18.png

View solution in original post

6 REPLIES 6

Hi @kim-lindgren,

 

Here's how I've just confirmed that 'answer = true;' does indeed block access - see the below screenshot.

Essentially, strip back the logic to confirm.

I added this User Criteria to a standard Catalog Item and added this under the 'Not Available For' against an item. I checked that when set to true, the user could not see the item. When set to false, the user could see the item. 

As an FYI, whilst in the script itself there is the below statement, I did have to clear the cache to confirm as I too was getting indifferent results until I cleared the cache and also logged out and logged back in.

I did say they were 'fun' didn't I. 

"Scripted User Criteria is not cached, and evaluated everytime, so performance is dependent on the script."

 

Also, as per the guidance, remove the statement: !gs.getUser().isMemberOf("GROUP");

You're going to have to user the 'user_name' object (which is the sys_id of the user which the evaluation is against.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 
 
Screenshot 2024-02-07 at 15.42.18.png

Thanks Robbie, I can also confirm now that this is indeed what happens.

 

The logic turned out to be correct, even if gs.getUser() was used.

 

  • If the user is a member of company A and *not* a member of the group in the script, the user criteria will return true and the user will *not* have access.
  • If the user is a member of company A and *is* a member of the group in the script, the user criteria will return false (based on the Match All condition) and the user *will* have access.

My bigger headache was trying to replace gs.getUser() with "user_id". as it says in the docs. Sadly, the documentation isn't very clear: What finally worked was to use g_user_userID, thus

answer = !g_user.userID.isMemberOf("GROUP");

 

I hope this helps someone.

 

Cheers,

Kim