- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2015 07:43 AM
I have 4 queries... 2 going to incident table, 1 going to sc_request and the last going to sc_task. Is there a way that I can combine these 4 into 1? The reason being is I am wanting to order the results based on a datetime field for all 4 queries. I have 4 while loops looping through the results, it only orders each while loop, not the whole result set from all 4 queries...
Basically what I am trying to do is order the results of all 4 queries together, not individually... right now it is ordering them individually, so when I display it in a table it is not showing an accurate order.
FYI: This is in a UI Page.... so maybe I am a little handcuffed on what I can do...
If combining the queries is not the best way, can someone explain to me a way that I can achieve this in Servicenow?
<g:evaluate>
var inc = new GlideRecord('incident');
inc.addQuery('is_valid', 'true');
inc.addQuery('active', 'true');
inc.orderBy('logged_time');
inc.query();
var incUpdate = new GlideRecord('incident');
inc2.addQuery('active', 'true');
inc2.addQuery('type', 'First Location');
inc2.addQuery('state', 'Open');
inc2.orderBy('date');
inc2.query();
var req= new GlideRecord('sc_request');
req.addQuery('active', 'true');
req.addQuery('type', 'First Location');
req.addQuery('state', 'Open');
req.orderBy('date');
req.query();
var tsk = new GlideRecord('sc_task');
tsk .addQuery('active', 'true');
tsk .addQuery('type', 'First Location');
tsk .addQuery('state', 'Open');
tsk .orderBy('date');
tsk .query();
</g:evaluate>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2015 07:55 AM
Hi Josh,
Is there any relation between the data of these tables you are querying? If there is then you could maybe do it with a Database view?
Also, I see the last 3 GlideRecords calls are with same filters, and taking into account that all these tables are extensions of task, can't you do only one GlideRecord call on task with a sys_class_name condition to be table incident/sc_request/sc_task?
Regards,
Sergiu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2015 08:38 AM
I am not good at jelly I wouldn't be of much help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2015 08:40 AM
Jelly scripting is no fun! If I had a choice I wouldn't use it. Haha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-11-2015 09:04 AM
You are correct, I ended up using task table and dot walking to get what I needed. Thank you