Reputation: 4047
I'm using xml web service for service-now to query on the incident records. I'm using java and apache Httpscomponents to make calls. Since I am having a large number of records, In want to filter those records based on the sys_updated_on. What I tried is passing below uri to the HTTPGet
https://<instance>-now.com/incident.do?CSV&sys_param_query=active=true^sys_updated_onBETWEENjavascript:gs.dateGenerate(2016-12-01,03:50:00)@javascript:gs.dateGenerate(2016-12-01,03:55:00)
But this doesn't worked for me as it is returning all records, not the filtered ones. Can someone please tell me what I am doing wrong here and the correction too. Thanks
Upvotes: 3
Views: 6632
Reputation: 4047
Found the solution from servenow.com only.
https://<instance>-now.com/incident_list.do?sysparm_query=sys_updated_onBETWEENjavascript%3Ags.dateGenerate('2016-12-01'%2C'00%3A00%3A00')%40javascript%3Ags.dateGenerate('2016-11-20'%2C'23%3A59%3A59')
or
https://<instance>-now.com/incident_list.do?sysparm_query=sys_updated_onBETWEENjavascript%3Ags.dateGenerate('2016-12-01','00:00:00')%40javascript%3Ags.dateGenerate('2016-11-20','23:59:59')
how did I found this? On your_instance.servicenow.com, when we press on the filter button, a filter line is shown in its right, right click on that and select copy url. Attached is the image for same.
Upvotes: 6
Reputation: 196
This is working for me from the browser at least, one difference I see is in the way the date's are formatted in your snippet:
https://<instance_url>/incident_list.do?CSV&sysparm_query=active%3Dtrue%5Estate!%3D6%5Esys_updated_onBETWEENjavascript%3Ags.dateGenerate('2016-11-01'%2C'00%3A00%3A00')%40javascript%3Ags.dateGenerate('2016-12-07'%2C'23%3A59%3A59')
Upvotes: 0
Reputation: 4225
Make sure date and time strings are in quotes.
https://<instance>-now.com/incident.do?CSV&sys_param_query=active=true^sys_updated_onBETWEENjavascript:gs.dateGenerate('2016-12-01','03:50:00')@javascript:gs.dateGenerate('2016-12-01','03:55:00')
Upvotes: 0