Query parameters in the End point URL

srinivas60
Tera Contributor

I have 2 fields Begin date and End Date

How to query the records based on the(begin date <= Today and End Date >= Today) in REST Messages using the GET 

 

Tried with the below code in Script include;

var gdt = new GlideDateTime(gs.nowDateTime());
var tdydate = gdt.getDate();
var filter = '%24filter%3DBegindate%20le%20DateTime%27'+tdydate+'T00%3A00%3A00%27%20and%20Enddate%20ge%20DateTime%27'+tdydate+'T00%3A00%3A00%27';

 

Thanks in advance

 

4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Can you try

start_date<=javascript:gs.endOfToday()^end_date>=javascript:gs.beginningOfToday()

Replace start_date & end_date as per your field name

We are integration with SAP we need to pass this filter in query parameters in URL.

This looks fine in Servicenow Query

I understand  but all you need is to navigate to

System Webservices >> REST >> REST API Explorer

Select a table & the copy the encoded query

I did try & got something as below

https://abc.service-now.com/api/now/table/change_request?sysparm_query=start_date%3C%3Djavascript%3Ags.endOfToday()%5Eend_date%3E%3Djavascript%3Ags.beginningOfToday()&sysparm_limit=1

 

Where abc is my instance name. Use above & just replace start_date & end_Date & table name accordingly

Thanks for the reply

Tried it, not working

We are apply filter on the 3rd party system(servicenow to SAP) using the GET method

Trying to filter with the the URL