Provide year filter in sysparams in a table REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 04:45 AM
Dear All,
I want to set up parameters for a table and access this as a REST API.
For this, I want to set a filter in sysparams as 'where table-column = to_year(sysdate)' -- so i want to filter all the records of the table where column value is same as the current year.
How can i provide this sysparams?
Best Regards,
Ashwini Pingle

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 05:52 AM - edited 08-11-2023 05:53 AM
Hello,
To provide the sysparams for your filter, you need to use the sysparm_query parameter and encode your query using the ServiceNow query syntax. For example, if you want to filter all the records of the incident table where the opened_at column value is the same as the current year, you can use this sysparm_query:
sysparm_query=opened_atONThis%20year@javascript:gs.dateGenerate('','')
This will encode the query
opened_atONThis year@javascript:gs.dateGenerate('','')
which means that the opened_at date is on this year.
You can also use other operators and functions to create more complex queries. You can find more information about the query syntax and how to encode it here.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 10:43 PM
Thanks a lot for your response. I tried the javascript as follows and was able to provide the year parameter in the sysparams
I could also do a year+1 filter