- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 07:06 AM - edited 05-16-2024 07:06 AM
Hi,
How can I make a field in a catalog item visible only if the currently logged-in user is in group 'A' or 'B'? I attempted to achieve this using a UI Policy, but it wasn't successful. I've attached the script.
function onCondition() {
if (g_user.isMemberOf("A") || g_user.isMemberOf("B")) {
g_form.setVisible("field-name", true);
} else {
g_form.setVisible("field-name", false);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 07:19 AM
Hi,
isMemberOf function is part of gs api which is a server side API.
Please check the below community post it would be helpful.
Regards,
Karthik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 07:12 AM
try to create role and use g_user.hasRole('role_name'), make sure you are testing with non-admin user once you update the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 07:15 AM
Hi @andreea_luca ,
Write onLoad catalog client script and check for group membership via code which you already shared.
Let us know if it works or not.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2024 07:19 AM
Hi,
isMemberOf function is part of gs api which is a server side API.
Please check the below community post it would be helpful.
Regards,
Karthik