How can we fetch the sys_id or name from related CI of CMDB Service table

YUVRAJS
Tera Contributor

Hii Team,

     i want a script which can be help me fetching the name or sys_id of the linked service offering  to the cmdb_ci_service table.

as you can see in the screenshot. for fetching the name or sys_id of the service offering. 

Screenshot 2024-06-04 194037.png

1 REPLY 1

richardbrounste
ServiceNow Employee
ServiceNow Employee

try this:

 


var service_sysid = '<Service Sys ID>';
var cirelgr = new GlideRecord ( 'cmdb_rel_ci' );
cirelgr.addQuery ( 'parent', service_sysid );
cirelgr.addQuery ( 'type', '6afd799338a02000c18673032c71b87b' ); /*** sysid for the cmdb_rel_type Used by::Uses ***/
cirelgr.query();
if (cirelgr.next())
{
gs.info ( "Sysid for the related Service Offering:" + cirelgr.child );
}