how to check whether record exists in related list using BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2021 03:32 AM
Hi ,
i want to check whether there is at least one record in related list , if it is there fine. if there is no record show error message that as "please add one record at least"
and these check has to done when it is changing from new to work in progress.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2021 02:28 PM
Hi Sasi,
If my answer is helpful please mark my appropriate answer as correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 10:56 AM
Hi @Balaji
I have the same requirement on change form, incidents pending related list tab should have atleast one entry.
I used the same code on change table using before business rule (update ) with filter conditions as priority 1 ,breakfix as ABC and classification as DEF

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2021 03:42 AM
Hi Sasi,
Here is the code:
Onsubmit script
function onSubmit() {
var istrue = g_form.getValue('u_relate_to_project');
if(istrue == 'true')
{
var curSysid = g_form.getUniqueValue();
var ga = new GlideAjax('check_projects_exists');
ga.addParam('sysparm_name','isProjectExist');
ga.addParam('sysparm_currentsysid', curSysid);
ga.getXMLWait();
var answer = ga.getAnswer();
if(answer == 'Not Exist')
{
alert('please add one record at least');
return false;
}
}
}
__________________________________
scriptInclude
Name : check_projects_exists
Active : true
Client callable : true
Script:
var check_projects_exists = Class.create();
check_projects_exists.prototype = Object.extendsObject(AbstractAjaxProcessor,
{
isProjectExist: function()
{
var answer ='';
var cursysid = this.getParameter('sysparm_currentsysid');
gs.log('cursysid :'+cursysid);
var gr = new GlideRecord('task');
gr.addQuery('parent', cursysid);
gr.query();
if(!gr.next())
{
answer = "Not Exist";
}
else
{
answer = "Exist";
}
return answer;
}
});
Please mark my answer as Correct & Helpful, if applicable.
Thanks
Sandeep