- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 11:33 PM
Hi All,
I have a User criteria with following conditions in the Available for related list:
if(gs.hasRole('rolename')){
return true;
}
else if(gs.isMemberOf('grp_name')){
return false;
}
else {
return false;
}
When testing its not working properly, first I added the role used in condition to the user then that particular category was visible - correct working. Then removed the role and added user to the group, the category is still visible.It should not be visible- not working.
I have tried clearing cache, and when logs were added to the user criteria noticed that it only works first time when impersonated by the user.
How to fix this?
Regards,
Snehal K
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2020 04:50 AM
Hi All,
Thanks for the advice. After further testing found that it was a cache issue. The script worked properly,checked by logs.
After clearing the cache it worked properly
Thanks,
Snehal Khare

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 05:16 AM
Here is what your script looks like (in a beautified format):
if(gs.hasRole('rolename')){
return true;
} else if(gs.isMemberOf('grp_name')){
return false;
} else {
return false;
}
This can be stripped down to:
if(gs.hasRole('rolename')){
return true;
} else {
return false;
}
Which means, that all ELSE parts always return false.
If that is true, you really do not need any script.
Maybe you just have some simple error, and your script should return "true" after the "else if". If YES, still that can be done without code..
So, I think you need to review the desired return codes of your script.
That will sort out your problem.
Let me know how it works out.
BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 05:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2020 04:50 AM
Hi All,
Thanks for the advice. After further testing found that it was a cache issue. The script worked properly,checked by logs.
After clearing the cache it worked properly
Thanks,
Snehal Khare