- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2022 12:22 AM
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:
and next to the line 18: Parsing error: Unexpected token 0
Thanks in advance for help
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2022 12:32 AM
keep the encode query under double quotes "". This will remove any issues that are arising due to many single quotes inside the encoded query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2022 12:32 AM
keep the encode query under double quotes "". This will remove any issues that are arising due to many single quotes inside the encoded query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2022 01:02 AM
Thank you! Now it works 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2022 12:34 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader