- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 02:19 PM
I need to check on a record if the related list is empty, If it is empty then I want to show a UI action button. How can I accomplish this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 03:06 PM
Hello,
Please check this Article-
https://community.servicenow.com/community?id=community_question&sys_id=b9c1df6ddbdcdbc01dcaf3231f961987
Regards,
Surendra Deshmukh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 03:00 PM
You need a script include with script to check if record exists in the related list by querying the related table.
Then Create your UI action and in the condition, call the above script to check if related list is empty.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 03:06 PM
Hello,
Please check this Article-
https://community.servicenow.com/community?id=community_question&sys_id=b9c1df6ddbdcdbc01dcaf3231f961987
Regards,
Surendra Deshmukh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 05:06 AM
Hi samadam,
You can write following script include for that. For instance i have considered related list of roles in user form. Likewise you can do it as per your requirement.
var checkRelatedList = Class.create();
checkRelatedList.prototype = {
checkRelatedList: function() {
var gr = new GlideRecord("sys_user_has_role");
gr.addQuery("user", current.sys_id);
gr.query();
var count= gr.getRowCount();
if(count==0)
return true;
else
return false;
},
type: 'checkRelatedList'
};
And in the UI action in the condition field you can call the script include function as:
new checkRelatedList().checkRelatedList();
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2018 05:13 AM
Thank you, I got it working.