- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 07:08 PM
Use case:- There should be a button (named as- Assigned Me) at the top, this button should only display to users who belongs to the selected assignment group mentioned below the Assignment group field in the incident record. Means when the logged in user selects the assignment group from the assignment group field and he belongs to that group then that button should be visible to him.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 03:40 AM
Hi @Kruthik45 ,
Create a UI action as below
(Make sure you save the form once assignment group is selected to see UI hide/show logic)
//Condition
gs.getUser().isMemberOf(current.assignment_group)
//script
current.assigned_to = gs.getUserID(); //set logged in user has assigned to
current.update(); //update
Hope this help!!!
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2024 01:12 AM
Hi @Kruthik45
Condition section is only to control button visibility (hide/show)
if you want to write multiple line then use &&, || conndition , if its multiple condition and does fit in the condition section use script include and call it from condition section
ex 1: to check logged in user is part of the current assigment group and has ITIL role
gs.getUser().isMemberOf(current.assignment_group) && gs.hasRole("itil")
ex 2: To write multiple line of code using script include
gs.getUser().isMemberOf(current.assignment_group) && gs.hasRole("itil") && new checkCondition().sampleCode()
script include:
Hope this helps!!!
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 03:40 AM
Hi @Kruthik45 ,
Create a UI action as below
(Make sure you save the form once assignment group is selected to see UI hide/show logic)
//Condition
gs.getUser().isMemberOf(current.assignment_group)
//script
current.assigned_to = gs.getUserID(); //set logged in user has assigned to
current.update(); //update
Hope this help!!!
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 03:52 PM
Hi @Hemanth M1 ,
Unlike this case, what if I had to write multiple lines of code in the condition section? Can I write my conditions in the script section? Or is it only used for specifying click actions?
Thank you,
Pavan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2024 01:12 AM
Hi @Kruthik45
Condition section is only to control button visibility (hide/show)
if you want to write multiple line then use &&, || conndition , if its multiple condition and does fit in the condition section use script include and call it from condition section
ex 1: to check logged in user is part of the current assigment group and has ITIL role
gs.getUser().isMemberOf(current.assignment_group) && gs.hasRole("itil")
ex 2: To write multiple line of code using script include
gs.getUser().isMemberOf(current.assignment_group) && gs.hasRole("itil") && new checkCondition().sampleCode()
script include:
Hope this helps!!!
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2024 03:56 PM
Hi @Hemanth M1 ,
Thank you. Unlike in this case, what if I had to write multiple lines of code for a condition, not just a single line? Can I use the script section to specify my condition, or is it only exclusive to specifying click actions?
Thank You,
Pavan