Add Year Choices to "Get Date Filter Options for Date Filters" Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 10:38 AM
Hi,
I found this article which makes sense to me to add a new choice into the Date Filter https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0749822. The thing is that I would like to include years, like 2020, 2021 and 2022 to be displayed in the filter.
Is that possible? If so, can anyone help me how to do that?
Regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2022 11:04 AM
I think you can, as in you can create filter in list layout as after 01/01/2022 or before 31/12/2022 and use that create a new interactive filter option.
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2022 03:38 PM
Hello Aman,
I tried the following below. I copied the query from the list layout, but I don't see it in the filter. Do you have any idea? It is the last line.
answer.add('170_Last 45 minutes@javascript:gs.minutesAgoStart(45)@javascript:gs.minutesAgoEnd(0)', gs.getMessage('Last 45 minutes'));
answer.add('175_One year ago@javascript:gs.monthsAgo(12)@javascript:gs.endOfThisMonth()', gs.getMessage('One year ago'));
//DIO
answer.add('180_2020 year@javascript:gs.dateGenerate(2020-01-01','00:00:00)@javascript:gs.dateGenerate(2020-12-31','23:59:59)', gs.getMessage('2020'));
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2022 12:29 AM
getMessage() is something you use with UI message, that holds a string value,
Go to left navigation, type Message and add a entry for 2020, you can similarly check what values are set for Last 45 minutes, One year ago.
You can also try with:
answer.add('180_2020 year@javascript:gs.dateGenerate(2020-01-01','00:00:00)@javascript:gs.dateGenerate(2020-12-31','23:59:59)', '2020');
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2022 03:12 PM