EncodedQuery to pull out incidents updated 2 days ago?

dianemiro
Kilo Sage

Hi Everyone,

I'm trying to pull out incidents via background script that is updated 2 days ago. But it returns 0 record. But when I checked manually on the list. There are records that are last updated 2 days ago. Thank you so much for your help.

Regards,
Diane

1 ACCEPTED SOLUTION

dianemiro
Kilo Sage

I was able to create an EncodedQuery for this and it gives me the results I need. Regardless, thank you all for your response.

gr.addEncodedQuery('sys_updated_onBETWEENjavascript:gs.daysAgoStart(2)@javascript:gs.daysAgoEnd(2)');

View solution in original post

11 REPLIES 11

Hi Diane,

So what query you are applying in the filter to get the records from the table list? copy same and use that?

Is it not working for the same?

Also can you share the background script here?

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

DirkRedeker
Mega Sage

Hi

You wrote, you are using encoded queries in scripts. I think, they are harder to read, then using "addQuery" Statements in the GlideRecord.

Try to convert your encoded query to single:

 

gr.addQuery(..);

 

statements. That will make your code more maintainable for the future. If you can solve your issue with that, it may be a good proof, that it may be better NOT using encoded queries in scripts.

Let me know if that solved your issue, and mark my answer as correct and helpful.

BR

Dirk

Matthew Smith
Kilo Sage

Hi Diane

If you change your query to show Incidents updated 'at or before' 2 days ago do you get results? If yes, then it looks similar to this thread which suggests is a known issue - albeit I can't access the PRB record mentioned:

https://community.servicenow.com/community?id=community_question&sys_id=dc9588b5db607f0013b5fb243996...

Hope it helps.

Matt

dianemiro
Kilo Sage

Does anyone know how can I add Last 2 days, Last 6 days to this?

find_real_file.png

This may help you.

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali