- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 09:06 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 08:00 AM - edited 02-07-2024 08:12 AM
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 08:00 AM - edited 02-07-2024 08:12 AM
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 11:44 PM
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