Can I filter a datetime field with a javascript snippet?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2015 06:12 AM
I have a report on which I want to dynamically change the datetime filter based on other conditions. I can write a script include to return the datetime value to filter. But am I able to create a filter condition on a datetime field that uses javascript?
I know I can do this on string field types -- like:
Name | is | javascript:mycustomfunction();
But on datetime fields, the condition builder suggests preset values like Today, Yesterday, Tomorrow, etc.. I don't see an opportunity to type in a "javascript: ..." string.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2019 07:57 AM
Thank you Troy,
one small thing: this only works on a Classical UI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 12:09 AM
I used this workaround.
Using JavaScript for DateTime field in new Conditi... - ServiceNow Community