addActiveQuery() and addEncodedQuery()

nataliya_b
Tera Guru

Hello All

I am running script include function and just notice that

this code lines sequence does not filter for active records

var gr = new GlideRecord(someTable);

gr.addActiveQuery();

gr.addEncodedQuery(strQuery); //

gr.query();

but this one does

var gr = new GlideRecord(someTable);

gr.addEncodedQuery(strQuery);

gr.addActiveQuery();

gr.query();

 

I could not find any docs regarding this 

Does anyone have the same experience? Where could I read about it?

thank you

1 ACCEPTED SOLUTION

Does the encoded query contain an or condition? Or (multiple) layered and conditions?

Then it would matter if the active=true is at the beginning. Or at the end and then part of an or condition for example.

View solution in original post

13 REPLIES 13

Kieran Anson
Kilo Patron

Hi,

Can you use the getEncodedQuery() method to see what the query string built looks like. Using your example, I don't see a discrepancy. What does 'strQuery' contain? This string could be interfering.

  find_real_file.png

find_real_file.png

Hello Kieran

Thank you for your reply. 

The query is dynamic and it is complicated. 

I run the same test as you did and final query with active=true at the end of string brings correct records, but when it is in the beginning - no filer for active

What in query string could interfere to make final query not to select active records?

any ideas? 🙂

Are you able to paste the query string in here?

It'll depend on whether your condition contains an OR condition or a contradictive active=false statement.

What is the playground you use to run the code?