Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 02:27 AM
what's your exact question?
you can do something like this
Also I optimized the script as there is no need of while since the only objective is to get the total count; you can use getRowCount()
var count = 0;
var server = ['sysId1','sysId2','sysId3'];
var serverrel = new GlideRecord('cmdb_ci');
serverrel.addEncodedQuery('parent.operational_status=1^child.sys_idIN' + server.toString());
serverrel.query();
count = serverrel.getRowCount();
gs.log("count"+count);
return JSON.stringify(count);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader