Not able to Fetch Multiple records using GlideRecord at time of checking

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 05:08 AM - edited 05-14-2024 05:10 AM
Hi Team
Below is my script Include function.The requirement is when there is no record in contact Relationship table , this should insert/create the multiple records based on multiple accounts and single contact which it does without any issues.
But when we try to fetch the already existing records for Account , this only returns single record.
In other words the Else condition is working fine, its only IF the record is found, it only returns single record and not more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 05:17 AM
Hi @Community Alums
try the below code .
arr.push(gr.sys_id.toString());
gs.info('Total Account:' + arr.toString());
var rel = new GlideRecord('sn_customerservice_contact_relationship');
rel.addQuery('company', arr);
rel.addQuery('contact', contact);
rel.query();
while (rel.next()) {
gs.addErrorMessage('Contact Relationship record already exist:' + rel.company.name);// This is just printing 1 account and not more..
return rel.company.toString();
}
Thanks
dgarad