- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 06:05 AM
Hi ServiceNow Community,
We have a UI action button on the form and on the form there is a reference field 'Department' which is referring to department table , and on the department table there is 'approval group' field (reference field to groups table).
We would need to show an Info message when user click on the UI action button if there are no group members available on the approval group(approval group is field is on the department table) . I need the logic in the UI action button to show the message when user click on it.
Please help on how to achieve this ,
Regards,
Sagar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 06:08 AM
should be an easy task
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", current.departmentField.groupField);
gr.setLimit(1);
gr.query();
if(!gr.hasNext()){
gs.addErrorMessage("There are no members in the group associated with the department");
return false;
}
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
08-01-2023 06:08 AM
should be an easy task
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", current.departmentField.groupField);
gr.setLimit(1);
gr.query();
if(!gr.hasNext()){
gs.addErrorMessage("There are no members in the group associated with the department");
return false;
}
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
08-01-2023 06:08 AM
Why not hide that UI action if there are no group members in the group associated with the department on the form?
You can use UI action condition and use script include and check this
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
08-01-2023 06:30 AM
Hi @Ankur Bawiskar ,
Thank you for your reply, we are setting the status back to draft status if there are no members in the group associated with the department on the form.
Regards,
Sagar