I want to show the button, if the logged in user is part of an assignment group using UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 05:35 AM
I want to show the button, if the logged in user is part of an assignment group using UI action.
I tried to use this code -- gs.getUser().isMemberOf(current.assignment_group).
Can anyone help me on this why it is not working in UI action.
UI action checked fields:
1. Show Update - checked
2. Client - Checked
3. Form Button - Checked.
Condition:
current.u_rfc_type=="Standard" && current.u_request_cancellation=="true"&¤t.assignment_group.type.getDisplayValue()=="Abc Fulfiller"&&gs.getUser().isMemberOf(current.assignment_group)
It is working up to this condition:
current.u_rfc_type=="Standard" && current.u_request_cancellation=="true"&¤t.assignment_group.type.getDisplayValue()=="Abc Fulfiller"
Not working if add the below condition for the above code:
&&gs.getUser().isMemberOf(current.assignment_group)
Is anyone face the same issue?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 05:49 AM
In a UI Action an easy way to hide/show an element based on role is to put the role requirement into the condition field.
I have a button that I show if a user has a specific role and the change is in a specific state. So my condition looks like this:
gs.hasRole('abc_manager') && current.state == 8 || gs.hasRole('abc_manager') && current.state == 7
This will allow the button to show when the user has the appropriate role.
Hope this helps.
Isaac

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 05:52 AM
Hi,
It looks fine to me.
Not sure if maybe the max length of the condition field is what you're hitting. You could look in to that or perhaps look in to creating a script include and reference that there in the condition instead, per this link: https://community.servicenow.com/community?id=community_question&sys_id=52501729dbdcdbc01dcaf3231f96...
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 06:06 AM
Hi Allen,
Thanks for the prompt response.
In my case, i tried with only this condition , to test --- gs.getUser().isMemberOf(current.assignment_group).
Then also it is not working.
Note: when the form is onload the button is coming, after completion of the form load.. the button disappearing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 07:18 AM
And is the user a moment of the assignment group? You've went and verified that?
Because that looks right, the way you have it. Can you share a screenshot as well?
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!