- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2020 03:02 AM
Hi guys, I have script:
var gr = new GlideAggregate('incident');
gr.addEncodedQuery("active=true");
gr.addAggregate('COUNT');
gr.query();
var result = 0;
if (gr.next())
result = gr.getAggregate('COUNT');
gs.print("Total number of Active Incidents: " + result);
var gr2 = new GlideAggregate('incident');
gr2.addEncodedQuery("active=true^contact_type=phone");
gr2.addAggregate('COUNT');
gr2.query();
var result2 = 0;
if (gr2.next())
result2 = gr2.getAggregate('COUNT');
gs.print("Total number of Active Incidents with Phone contact: " + result2);
As you can see only the addEncodedQuery changes. Is there any way to "merge" this two script somehow to one, and just have 1 GlideAggregate call?
Thanks a lot!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2020 03:30 AM
Hi
As they are 2 separate queries so you can't merge those things up.
You can use database views to merget 2 tables together and gliderecord on it .
Check this link
https://codecreative.io/blog/3-strategies-to-fix-nested-gliderecords/
Regards
Pranav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2020 03:11 AM
Hi,
Do you want count of active=true and contact_type=phone then you need to use 2nd query
Both the queries are different
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2020 03:30 AM
Hi
As they are 2 separate queries so you can't merge those things up.
You can use database views to merget 2 tables together and gliderecord on it .
Check this link
https://codecreative.io/blog/3-strategies-to-fix-nested-gliderecords/
Regards
Pranav