Condition for 60 day date validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
5 hours ago - last edited 5 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
3 hours ago
the latest approach of using client callable script include worked fine for me
Please use that and let me know the feedback
💡 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
13m ago
Hi @Ankur Bawiskar
my script include works fine. I've checked it in a background script and it returns 1 record as expected. But when I try to call it in a condition, it doesn't work.
var GetMyRecordsScriptInclude = Class.create();
GetMyRecordsScriptInclude.prototype = {
initialize: function() {},
getMyRecords: function() {
var resultArray = [];
var gr = new GlideRecord('<my_database_view>');
gr.addQuery('payroll_state', '18'); //WIP state
gr.query();
var today = new GlideDateTime();
while (gr.next()) {
var dateString = gr.getValue('qa_value');
if (!dateString) {
continue;
}
var recordDate = new GlideDateTime(dateString);
recordDate.addDaysUTC(60);
if (today.after(recordDate)) {
resultArray.push(gr.getValue('payroll_sys_id'));
}
}
return resultArray.join(',');
},
type: 'GetMyRecordsScriptInclude'
};
Database view-> the same result
