- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 12:46 PM - edited 03-02-2023 01:22 PM
Hi,
I have a button I need to hide if the current user is not in a given group.
Would that be too much to put into the Condition field?
If so, I found this link which looks helpful but I'm not sure what to put in to actually hide the button (in that link they're hiding State options). Would I just nest the button code in there and add a Return statement? For example:
function onLoad() {
var usr = g_user.getUserID();
if (!g_scratchpad.grp){
return; //end function before button displays
}
//button code
}
EDIT: Nope, didn't work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 02:21 PM
I figured it out. In the Condition:
gs.getUser().isMemberOf('group name here') == true
Thanks 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 01:00 PM
Best practice would likely be to call a script include in the UI actions condition field.
In your script include query the grmember table for the currently logged in user, then compare the returned records group fields against the group you're checking if the user is not in.
If you find a match, return false (hide the button)
else return true (show the button)
Let me know if this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 01:25 PM
Hi,
Thanks for your reply.
That produces the following error: "The object "gs" should not be used in client scripts."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 02:21 PM
I figured it out. In the Condition:
gs.getUser().isMemberOf('group name here') == true
Thanks 🙂