Scripted Date/Time inputs for Flow Designer causing issues with integration hub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 08:57 AM
I'm using the Amazon Connect spoke for "Get Metrics Data" which requires a start and end time to be populated on execution. The flow is set to execute every 5 minutes in order to refresh the metrics displayed in ServiceNow.
The start/end time will only accept a value rounded to the nearest 5 minute mark. Example: 9:00, 9:05, 9:10, etc. I've created a script achieving the rounded value at time of flow execution. What I'm seeing in return is the correct start and end times however the response body is null.
Response Body:
{"NextToken":null,"MetricResults":[{"Dimensions":null,"Collections":[]}]}
If I manually populate the start date but leave the scripted end date, the response body works. Am I missing a step?
Response Body:
{"NextToken":null,"MetricResults":[{"Dimensions":null,"Collections":[{"Metric":{"Name":"QUEUED_TIME","Threshold":null,"Statistic":"MAX","Unit":"SECONDS"},"Value":218.0},{"Metric":{"Name":"QUEUE_ANSWER_TIME","Threshold":null,"Statistic":"AVG","Unit":"SECONDS"},"Value":57.0}]}]}
Start Time script:
var start_gdt = new GlideDateTime(); // Current Date and Time
var milliseconds = start_gdt.getNumericValue(); // Get time in milliseconds
var fiveMinutes = 5 * 60 * 1000;
// Round DOWN to the nearest 5 minutes
var roundedMilliseconds = Math.floor(milliseconds / fiveMinutes) * fiveMinutes;
// Set the rounded value back to a GlideDateTime object
start_gdt.setNumericValue(roundedMilliseconds);
outputs.start_time = start_gdt;
End Time script:
var end_gdt = new GlideDateTime(); // Current Date and Time
var milliseconds2 = end_gdt.getNumericValue(); // Get time in milliseconds
var fiveMinutes2 = 5 * 60 * 1000;
// Round UP to the nearest 5 minutes
var roundedMilliseconds2 = Math.ceil(milliseconds2 / fiveMinutes2) * fiveMinutes2;
// Set the rounded value back to a GlideDateTime object
end_gdt.setNumericValue(roundedMilliseconds2);
outputs.end_time = end_gdt;