How do i fetch configuration item field value into incident table

Deepa12
Tera Contributor

Hi,

 

I want to retrieve incident number using the configuration item sys id. the below query didnt execute. pls let me know the corrrection in the script:
var ciname = "c9db69b797503590ce1536200153afbb";

var inc = new GlideRecord('incident');
inc.addQuery("cmdb_ci.name.sys_id=" + ciname);
inc.addQuery("active=true");
inc.query();
while(inc.next())
{
gs.print(inc.number);
}

1 ACCEPTED SOLUTION
2 REPLIES 2

shubhamdubey
Mega Sage
 
Use below snapshot for your referenceci.PNG

var inc = new GlideRecord('incident');
 
// passing the encoded query here
inc.addEncodedQuery('cmdb_ci.sys_idLIKEb4fd7c8437201000deeabfc8bcbe5dc1');
inc.addQuery("active=true")

inc.query();
while(inc.next())
{
gs.print(inc.number);
}

@Deepa12 

 

Here is output

output.PNG