- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019 04:08 AM
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...... ]
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019 07:26 AM
it would be parent_incident ,
rl.addQuery('parent_incident', dts.sys_id);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019 04:14 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019 04:20 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019 04:27 AM
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019 04:47 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2019 05:13 AM
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');
}