need to get entire details about a incident

Mr_Blue
Tera Expert

Hello Guys,

What i want is ::> Need entire details about a ticket in "Script-background", All details like [ Child ticket, assigned to, Assigned group, summary, create on, and so on...... ] 

Below code is not even showing me "Script-background", but its not giving me any output 

 

var dts = new GlideRecord('incident');
dts.addQuery('number','INC0010120');
dts.query();

if(dts.next()){ dts.info(' exists'); } else { dts.info('does not exists'); }

Can some one please show me how to get all the details about a ticket in code [ Child ticket, assigned to, Assigned group, summary, create on, and so on...... ]

1 ACCEPTED SOLUTION

it would be parent_incident , 

 

rl.addQuery('parent_incident', dts.sys_id);

View solution in original post

29 REPLIES 29

Harsh Vardhan
Giga Patron

it should be gs.info().

 

updated code. 

 

 

var dts = new GlideRecord('incident');
dts.addQuery('number','INC0010120');
dts.query();

if(dts.next()){ gs.info(' exists'); } else { gs.info('does not exists'); }

 

your script is checking  if the INC0010120 exist on incident table or not. if it exist then you will get first if block message, else you will get else block message. 

 

gs.info() work in scoped application to print the result. 

 

 

Hello Harshvardhan,

Thank you for replying me 

How to get other values like [ Child ticket, assigned to, Assigned group, summary, create on] for incident : INCXXXXXXX

something like below script. 

 

var dts = new GlideRecord('incident');
dts.addQuery('number','INC0746894');
dts.query();

if(dts.next()){ 
gs.print('Assigned To'+ dts.assigned_to.getDisplayValue()); 
gs.print('Assigned To'+ dts.assignment_group.getDisplayValue()); 
gs.print('Assigned To'+ dts.summary); 


var rl = new GlideRecord('incident');
rl.addQuery('parent', dts.sys_id);
rl.query();
if(rl.next()){

gs.print('Child incident'+rl.number);
}



} else { 
gs.print('does not exists'); 
}

 

refer the blog below for further details about glide record. 

 

https://www.servicenowguru.com/scripting/gliderecord-query-cheat-sheet/

 

 

Hello Harshvardhan, Thank you for helping me. 

Here In your code the below lines are not getting executed 
var rl = new GlideRecord('incident'); 
rl.addQuery('parent', 'INC0010120');
rl.query();
if(rl.next()){

gs.print('Child incident' + rl.number);
}

can you please help

you did not use the complete code which i have posted in my above reply.

 

try to use it and then run in your back ground script. first pass the incident number to get the child incident attached with the incident.

 

example: incident INC0010136 has 0ne child incident INC0010135

 

so your script will be like below. 

 

var dts = new GlideRecord('incident');
dts.addQuery('number','INC0010136');
dts.query();

if(dts.next()){ 
gs.print('Assigned To'+ dts.assigned_to.getDisplayValue()); 
gs.print('Assigned To'+ dts.assignment_group.getDisplayValue()); 
gs.print('Assigned To'+ dts.summary); 


var rl = new GlideRecord('incident');
rl.addQuery('parent', dts.sys_id);
rl.query();
if(rl.next()){

gs.print('Child incident'+rl.number);
}



} else { 
gs.print('does not exists'); 
}