The CreatorCon Call for Content is officially open! Get started here.

GlideAggregate and before query business rule

mennoaret
Kilo Explorer

Hi all,

I have a before query business rule to restrict knowledge articles for particular users. This is working fine when I do a GlideRecord query on the kb_knowledge table.

To explain the problem I am facing a bit more clearly here is an example.

Before query business rule script:

current.addQuery("active", "true");

gs.log(current.getEncodedQuery());

Script Include or background script with a GlideRecord query:

var gr = new GlideRecord("kb_knowledge");

gr.addQuery("workflow_state", "published");

gr.addQuery("published", "<=", gs.daysAgoStart(0));

gr.addQuery("valid_to", ">=", gs.daysAgoStart(0));

gr.query();

When I do a GlideRecord query this is working fine and I see the following log line:

workflow_state=published^published<=2015-07-22 07:00:00^valid_to>=2015-07-22 07:00:00^active=true

But when I am using GlideAggregate:

var countGr = new GlideAggregate("kb_knowledge");

countGr.addQuery("workflow_state", "published");

countGr.addQuery("published", "<=", gs.daysAgoStart(0));

countGr.addQuery("valid_to", ">=", gs.daysAgoStart(0));

countGr.addQuery("^ORDERBYtopic^GROUPBYtopic");

countGr.addAggregate('COUNT', "topic");

countGr.query();

When I execute this GlideAggregate script the query from the GlideAggregate is gone and I only can see the addQuery from the Business Rule in the log line:

active=true

Also when I do not add another addQuery in the business rule the query from the GlideAggregate is still missing.

I hope someone can help with this issue. This is something that should work in my opinion because the GlideAggregate is extending the GlideRecord.

I have tested this in Fuji, Eureka, Dublin and Aspen.

Hope to hear from you, thanks in advance.

Kind regards,

Menno Aret

Technical Service-Now Consultant for Logicalis SMC

3 REPLIES 3

mennoaret
Kilo Explorer

Hi all,



Ok I found out that the queries from GlideRecord and GlideAggregate are working and extended with the query from the before query business rule. The only thing to say about this is that it is regrettable that the query from the GlideAggregate can not be shown in the before query business rule with the function getEncodedQuery().



If someone has another option to get the query from the GlideaAggregate please let me know.


Thanks!



Kind regards,


Menno Aret


Very old thread, but I just ran into the same issue.  Wondering if you ever came across a solution.

 

API Documentation seems to indicate that Jakarta will fix this issue, but our next upgrade won't be until September, and this is causing an issue.

2024, Whashington. Just had a same issue. We are debugging some complex queries in CSM and I need to know what everything is applied, but I am not able to get output from GlideAggregate getEncodedQuery in before query BR, which is very unfortunate, as there are many business rules and query rules that are adding there something... So .. anyone any solution?