The CreatorCon Call for Content is officially open! Get started here.

Using sysparm_query with Incident table

thedavegray
Giga Expert

Hi all, 

 

Can I please get some starter advice on using the query parameter sysparm_query on the Incident table. 

 

Is it possible to get a date range based upon the sys_created_on field? So for example I would like to get just elements that match sys_created_on>=2022-01-21 AND <2022-01-22, I tried this but it does not work, it returns 

elements for 23rd, 24th etc,

 

sys_created_on%3E%3D2022-01-21&sys_created_on%3C2022-01-22

 

On the understanding that %3E%3D is >= and %3C is < (less than). 

 

Is it not possible to use multiple parameters with sys_created_on?

 

Screenshot of query running in Postman with values greater that 

 

thedavegray_0-1674573350666.png

 

Thanks 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Basheer
Mega Sage

It should be like this

sys_created_on>javascript&colon;gs.dateGenerate('2022-01-22','00:00:00')^sys_created_on<javascript&colon;gs.dateGenerate('2022-01-23','23:59:59')

 

Full link should be like this

 

https://instanceName.service-now.com/incident_list.do?sysparm_query=sys_created_on%3Ejavascript%3Ags...

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

View solution in original post

10 REPLIES 10

Hayo Lubbers
Kilo Sage

Hi,

Please create your desired filter within the application. Then you can right click on the query itself and copy it. You can use that in the sysparm_query to query the instance. Also the dynamic queries (last day, last month etc.) work perfectly.

 

Regards,

Hayo

 

Please mark the solution as correct, if the answer provided has resolved your query.

Basheer
Mega Sage

It should be like this

sys_created_on>javascript&colon;gs.dateGenerate('2022-01-22','00:00:00')^sys_created_on<javascript&colon;gs.dateGenerate('2022-01-23','23:59:59')

 

Full link should be like this

 

https://instanceName.service-now.com/incident_list.do?sysparm_query=sys_created_on%3Ejavascript%3Ags...

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

Hi @Basheer 

Thanks for the example.  I will have to have a play around with this later today in Postman to see if I can get it working. 

 

From your example, can I ask if the caret symbol means AND?  

 

sys_created_on>javascript&colon;gs.dateGenerate('2022-01-22','00:00:00')^sys_created_on<javascript&colon;gs.dateGenerate('2022-01-23','23:59:59')

 Thanks 

Yes caret (^) is AND

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.