4 days prior to Last day worked date field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 08:09 AM
Hi Community,
Good Day !
I have to trigger notification based on the condition "4 days prior to Last day worked date field" . I tried multiple things in condition builder but nothing is working fine. It returning unexpected records.
Please guide me how can build this condition in condition builder and use to trigger notification.
I also have attach the screenshot for the condition builder , I am using .
Thanks in advance 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 12:32 AM
Hello @TejashviT
You will not be able to achieve that in the list view rather you need a script like:
var glideRecord = new GlideRecord('your_table');
var todayDate = new GlideDate();
glideRecord.query();
while (glideRecord.next()) {
var lastDayWorked = glideRecord.getValue('last_day_worked');
var calculatedDate = new GlideDate();
calculatedDate.setValue(lastDayWorked);
calculatedDate.addDays(-4);
if (calculatedDate.equals(todayDate)) {
gs.info("Record exactly 4 days before 'last_day_worked': " + glideRecord.getDisplayValue('column_name')); // print the column
}
}
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 12:21 AM
Hi @TejashviT ,
The normal condition builder is not going to work for the purpose.
You will need to use script. You can use something like this as script:
Please mark the answer helpful and correct if it resolves the issue. Happy scripting 🙂
-Shantanu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2025 12:50 AM
you cannot achieve this using filter condition, you will need script for this
1) get the today's date
2) subtract 4 days
3) then compare that date against your date field value
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader