Encoded query not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 06:06 AM
Hi. My below encoded query is not working
I am passing data as parameter in API and its value is being sent as ( with single quotes) : '2025-01-08','00:00:00'
Can you pls help with the encoded query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 06:27 AM
Try the code below
taskGr.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate('" + dat + "')");
If my response helped please mark it correct and close the thread so that it benefits future readers.
Priyatam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2025 07:28 AM - edited 02-03-2025 07:36 AM
I am seeing two potential issues here:
- You're using ":" between "javascript" and "gs.dateGenerate" - that does not work in my testing (in background scripts); you should use an actual colon
- edit: looks like the community site automatically changes a colon to :
- You don't have the parentheses for gs.dateGenerate in the string for the encoded query
This should work:var date = "'2025-01-08','00:00:00'"; // string (doublequotes) enclosing two string parameters (in single quotes)
taskGr.addEncodedQuery("sys_created_on>=javascript:gs.dateGenerate(" + date + ")"); // use an actual colon instead of :
documentation for gs.dateGenerate: https://www.servicenow.com/docs/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/...