Issue with addEncodedQuery

Kasia5
Tera Contributor

Hi All,

I have an issue with addEncodedQuery in my Script Include. I've just added the copied query and I am not able to save because the error... I cannot see where is the issue

Script Include:

//Amount of all of the RITMs from last month and with SLA

getCount: function() {

var answer = '',
reqGA = new GlideAggregate('sc_req_item');

reqGA.addEncodedQuery('cat_item.delivery_time=javascript:gs.getDurationDate('0 8:0:0')^sys_created_onONLast month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()');
reqGA.addAggregate('COUNT');
reqGA.query();

if (reqGA.next()) {

answer = reqGA.getAggregate('COUNT');

}

return answer;
},

 

And query has been built on requested item table with filters:

Catalog Item Delivery Time = 8 hours

Created on Last month

 

Error which I see is:

find_real_file.png

and next to the line 18: Parsing error: Unexpected token 0

 

Thanks in advance for help

 

 

1 ACCEPTED SOLUTION

suvro
Mega Sage
Mega Sage

keep the encode query under double quotes "". This will remove any issues that are arising due to many single quotes inside the encoded query

View solution in original post

3 REPLIES 3

suvro
Mega Sage
Mega Sage

keep the encode query under double quotes "". This will remove any issues that are arising due to many single quotes inside the encoded query

Kasia5
Tera Contributor

Thank you! Now it works 🙂

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Point mentioned by other member should help you.

Just remember when you see single quote in the query; ensure to wrap it around with double quotes

regards
Ankur

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