Getting error while testing the flow designer
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 04:28 AM
Script written for the flow variable -
var startDT = fd_data._1__look_up_records.variables.start_date;
var startDateTime = new GlideDateTime(startDT);
var nowDateTime = new GlideDateTime();
var diffMillis = startDateTime.getNumericValue() - nowDateTime.getNumericValue();
// Check if current time is within one hour before start time
if (diffMillis > 0 && diffMillis <= 3600000) {
return true;
}
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 04:36 AM
Hi @Prithvi Ramesh1,
You need to use Action number 3 instead of Action 1 in your Flow script.
You need to access variable from each record at a time instead of all records.
var startDT = fd_data.<action_3_name>.variables.start_date;
var startDateTime = new GlideDateTime(startDT);
var nowDateTime = new GlideDateTime();
var diffMillis = startDateTime.getNumericValue() - nowDateTime.getNumericValue();
// Check if current time is within one hour before start time
if (diffMillis > 0 && diffMillis <= 3600000) {
return true;
}
Regards,
Ehab Pilloor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 04:38 AM
Hello @Prithvi Ramesh1 ,
var startDT_raw = fd_data._1__look_up_records.variables.start_date;
gs.info("Flow Script - Raw start_date from data pill: " + startDT_raw);
gs.info("Flow Script - Type of start_date: " + typeof startDT_raw);
var startDateTime;
startDateTime = new GlideDateTime(startDT_raw);
if (!startDateTime.isValid()) {
gs.error("Flow Script - ERROR: 'start_date' value could not be converted to a valid GlideDateTime object. Value: " + startDT_raw);
// return false; // Stop the flow/script due to invalid input
}
gs.info("Flow Script - startDateTime (display value): " + startDateTime.getDisplayValue());
gs.info("Flow Script - startDateTime (numeric value): " + startDateTime.getNumericValue());
var nowDateTime = new GlideDateTime(); // Get current server time (UTC internally)
gs.info("Flow Script - nowDateTime (display value): " + nowDateTime.getDisplayValue());
gs.info("Flow Script - nowDateTime (numeric value): " + nowDateTime.getNumericValue());
// Calculate the difference in milliseconds
var diffMillis = startDateTime.getNumericValue() - nowDateTime.getNumericValue();
gs.info("Flow Script - Difference in milliseconds (start - now): " + diffMillis);
// Define the one-hour threshold in milliseconds (1 hour = 3600 seconds * 1000 ms/second)
var oneHourInMillis = 3600 * 1000;
gs.info("Flow Script - One hour in milliseconds: " + oneHourInMillis);
if (diffMillis > 0 && diffMillis <= oneHourInMillis) {
gs.info("Flow Script - Condition MET: Current time is within one hour before start time.");
// return true;
} else {
gs.info("Flow Script - Condition NOT MET.");
// return false;
}
Check above script and see if it is working.
If my response was helpful, please mark it as correct and helpful.
Thank you.
Thank you.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2025 09:41 PM
Hello @Prithvi Ramesh1 ,
Did my answer resolve your question ?
If my response was helpful, please mark it as correct and helpful.
Thank you.
Thank you.