- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 03:55 PM
I have the following code in a script include.
updateCount : function (d1_id, mtype)
{
var count = new GlideAggregate ('u_ScanSearch');
count.addQuery ('parent', d1_id);
count.addQuery ('u_searchType.u_mtype', mtype);
count.addAggregate ('COUNT');
count.query ();
gs.log (d1_id + ' ' + mtype + ' ' + count.getAggregate ('COUNT'));
return parseInt (count.getAggregate ('COUNT'));
},
I am aware that getAggregate returns a string. Unfortunately the count.getAggregate lines both return nulls. I'm suspecting that u_searchType may be the culprit. mtype is supposed to be the display value of the reference field u_searchType (which has its own form u_searchType. Under GlideRecord, I can get this type of query to work, but it doesn't seem to be working for Aggregate.
Can someone confirm if GlideAggregate can work with dot walking? Or if not, can someone recommend an alternate approach?
Thanks
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 10:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2017 07:35 AM
Gargh, forgot about that. Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 10:40 PM
Also, Please check this thread if it helps: GlideAggregate not working on dot walked variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 10:42 PM
In place of
count.getAggregate ('COUNT')
Try
count.getRowCount()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2017 07:08 AM
The trouble with this approach is that it defeats the purpose of the GlideAggregate query. getRowCount() can cause performance issues since it iterates over every record in the result set and should be avoided.