- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 12:38 AM
Hi,
I need to create a new UI Action on the incident form (a button). The button needs to be displayed only when these conditions are met:
1) the login user is 'admin'.
2. the login user is a member of the current assignment group
3. the login user is a member of the parent's group of the current assignment group.
How can I achieve that? What should I type for the condition tab?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 05:27 AM
Hello @Alon Grod ,
You can utilize the script given below under the condition field of UI action form:
NOTE: your UI action should be in the global scope to work properly as "gs.getUser().isMemberOf" doesn't give desired result inside scoped applications.
!current.assignment_group.nil() && gs.hasRole('admin') && gs.getUser().isMemberOf(current.assignment_group.name) && gs.getUser().isMemberOf(current.assignment_group.parent.name)
In the above code, I've added one more condition to check empty assignment group field. But one thing I noticed that users with "admin" role automatically becomes member of the parent group of their respective group. For example: I have a user "XYZ" and he's an admin and also member of "Analyst" group, which is child of "Architects" group. But when I check in the background script that "XYZ" is a member of "Architects" group or not, it return true!
Although Servicenow Documentation suggests opposite:
"Parent: Other group of which this group is a member. The child group inherits the roles of the parent group. So, if a group has a parent, it inherits the roles of the parent group. However, the members of the child group are not members of the parent group."
Kindly Refer to https://developer.servicenow.com/dev.do#!/learn/learning-plans/tokyo/new_to_servicenow/app_store_lea... for more information about groups.
Kindly Mark my answer helpful and correct if it solves your question and helps you to understand the scenario better.
Tyhanks & Regards,
Shivam Jaiswal
Shivam Jaiswal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 12:41 AM
use this in UI action condition
gs.hasRole('admin') && gs.getUser().isMemberOf(current.assignment_group) && gs.getUser().isMemberOf(current.assignment_group.parent)
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 12:43 AM
@Alon Grod Please try the following in the condition field of the UI Action.
gs.hasRole('admin')&&gs.getUser().isMemberOf(current.assignment_group.name))&&gs.getUser().isMemberOf(current.assignment_group.parent.name))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 12:45 AM
Hi @Alon Grod ,
Use below condition
gs.hasRole('admin') && gs.getUser().isMemberOf(current.assignment_group) && gs.getUser().isMemberOf(current.assignment_group.parent.name)
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 05:27 AM
Hello @Alon Grod ,
You can utilize the script given below under the condition field of UI action form:
NOTE: your UI action should be in the global scope to work properly as "gs.getUser().isMemberOf" doesn't give desired result inside scoped applications.
!current.assignment_group.nil() && gs.hasRole('admin') && gs.getUser().isMemberOf(current.assignment_group.name) && gs.getUser().isMemberOf(current.assignment_group.parent.name)
In the above code, I've added one more condition to check empty assignment group field. But one thing I noticed that users with "admin" role automatically becomes member of the parent group of their respective group. For example: I have a user "XYZ" and he's an admin and also member of "Analyst" group, which is child of "Architects" group. But when I check in the background script that "XYZ" is a member of "Architects" group or not, it return true!
Although Servicenow Documentation suggests opposite:
"Parent: Other group of which this group is a member. The child group inherits the roles of the parent group. So, if a group has a parent, it inherits the roles of the parent group. However, the members of the child group are not members of the parent group."
Kindly Refer to https://developer.servicenow.com/dev.do#!/learn/learning-plans/tokyo/new_to_servicenow/app_store_lea... for more information about groups.
Kindly Mark my answer helpful and correct if it solves your question and helps you to understand the scenario better.
Tyhanks & Regards,
Shivam Jaiswal
Shivam Jaiswal