Condition for 60 day date validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago - last edited 4 hours ago
Hi,
I have to create a condition to meet the below requirement:
Date of today is greater than Date of field 'Sent for Approval' + 60 days. The Date of field 'Sent for Approval' is a variable and I was able to add its value in the Dashboard using database view. I want to check which condition will be better:
javascript:gs.daysAgoStart(60)or '60@days@ago'?
The value field is the date of the field 'Sent for Approval'
or
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
that's not going to work.
That value holds string and you can't compare it with another string which holds the filter.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
you can handle it like this
1) create classless client callable script include
2) call that in filter condition of data visualization
Sys Id [IS ONE OF] javascript: getMyRecords()
3) in that function form your query for State = Work In Progress and use GlideRecord on database view
-> then while you iterate grab the value field and store in GlideDate
-> compare it against today
-> if it satisfies then push that database view record sysId in array
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
29m ago
@Ankur Bawiskar
It seems like this solution won’t work. I can’t call a script include function in the filter condition of a data visualization because the data source is a database view. It might work for a regular table, but I don’t see an option to use Database view sys ID.
The sys_id of the database view is a unique identifier, not exactly a sys_id. Something similar like this "__ENC__MDZjMDgzNzRkYmQwNDAxMGY3Nzc1MjZhZGM5NjE5ZGU". That will be the sys_id for the database view
Database view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3m ago
you can push HR Case sysId in array and then in database view use something like this
hr -> prefix for HR Payroll database view table
hr_sys_id [IS ONE OF] javascript: getRecords()
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hey @miro2
To find records where Sent for Approval is older than 60 days, use:
60@days@ago is recommended for reports and dashboards because it is simpler, easier to read, and better optimized.
javascript:gs.daysAgoStart(60) should only be used when you specifically need script-based date logic.
*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
