GlideAggregate can it work with dot walking?

tahnalos
Kilo Sage

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

1 ACCEPTED SOLUTION

Little correction -   count.next()


View solution in original post

8 REPLIES 8

Gargh, forgot about that.   Thanks


Also, Please check this thread if it helps: GlideAggregate not working on dot walked variable?


Mihir Mohanta
Kilo Sage

In place of



count.getAggregate ('COUNT')



Try



count.getRowCount()


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.