If end date is prior 3 days or 1 day then trigger an email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2025 05:21 AM
If end date is prior 3 days or 1 day then trigger an email
If Opened date is prior 3 days and still it is un approver then trigger an email
Flow configuration:
Set Flow Varibale Script:
/*
**Access Flow/Action data using the fd_data object. Script must return a value.
**Order number is offset by +1 in Error Handling Section.
**Available options display upon pressing "." after fd_data
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/
gs.info("PRITHVI: Starting time difference calculation...");
// Get today's date
var today = new GlideDate();
// Get the end date from the Flow data
var endDate = fd_data._19__for_each.item.variables.end_date;
gs.info("PRITHVI: Retrieved end date = " + endDate);
// Calculate time difference in days between today and end_date
var timediff = gs.dateDiff(today, endDate, true) / 60 / 60 / 24;
gs.info("PRITHVI: Calculated time difference in days = " + timediff);
// Check if the time difference is exactly 1 or 3 days
if (timediff == 3 || timediff == 1) {
gs.info("PRITHVI: Time difference matches allowed values (1 or 3). Returning: " + timediff);
return true;
} else {
gs.info("PRITHVI: Time difference does not match allowed values. Returning: 'None'");
return false;
}
Flow Variable Code:
/*
**Access Flow/Action data using the fd_data object. Script must return a value.
**Order number is offset by +1 in Error Handling Section.
**Available options display upon pressing "." after fd_data
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/
gs.info("PRITHVI: Starting time difference calculation...");
// Get today's date
var today = new GlideDate();
// Get the end date from the Flow data
var endDate = fd_data._25__for_each.item.opened_at;
var gdt = new GlideDate(endDate);
gs.info("PRITHVI: Retrieved end date = " + gdt);
// Calculate time difference in days between today and end_date
var timediff = gs.dateDiff(today, gdt, true) / 60 / 60 / 24;
gs.info("PRITHVI: Calculated time difference in days = " + timediff);
// Check if the time difference is exactly 1 or 3 days
if (timediff == 3) {
gs.info("PRITHVI: Time difference matches allowed values (1 or 3). Returning: " + timediff);
return true;
} else {
gs.info("PRITHVI: Time difference does not match allowed values. Returning: 'None'");
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2025 05:24 AM
is this a question or knowledge sharing?
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2025 05:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2025 07:20 AM
@Prithvi Ramesh1
ok, I don’t see any configurations on the date verification.
for that either a separate flow or scheduled job would be required, either one option shall be triggered daily in early morning or late night hours
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2025 09:00 AM
Hello @Prithvi Ramesh1 , could you try to move Get Catalog Variables action to position 20 and then try to set the variable in position 21. also, modify the script as following
/*
**Access Flow/Action data using the fd_data object. Script must return a value.
**Order number is offset by +1 in Error Handling Section.
**Available options display upon pressing "." after fd_data
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/
gs.info("PRITHVI: Starting time difference calculation...");
// Get today's date
var today = new GlideDate();
// Get the end date from the Flow data
var endDate = fd_data._20__get_catalog_variables.start_date;
gs.info("PRITHVI: Retrieved end date = " + endDate);
// Calculate time difference in days between today and end_date
var timediff = gs.dateDiff(today, endDate, true) / 60 / 60 / 24;
gs.info("PRITHVI: Calculated time difference in days = " + timediff);
// Check if the time difference is exactly 1 or 3 days
if (timediff == 3 || timediff == 1) {
gs.info("PRITHVI: Time difference matches allowed values (1 or 3). Returning: " + timediff);
return true;
} else {
gs.info("PRITHVI: Time difference does not match allowed values. Returning: 'None'");
return false;
}
Regards,
Nishant