Show Info message when No user is part of the approval group

Sagar S
Tera Contributor

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

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Sagar S 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Sagar S 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@Sagar S 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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