Help with script in custom flow action - need to return value with date & time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 04:58 PM
I have a custom action for flow designer that nearly works, the correct date is returned but no time.
Action - Set date to first of month
Inputs:
Label Next audit date & Name u_next_audit_date with Type Date/Time
Script step
What is returned - (Correct date but no time stamp...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 05:11 PM
@Lon Landry4 Use getDisplayValue() insted of getValue(). Please see below updated script.
(function execute(inputs, outputs) {
// Parse the input date
var inputDate = new GlideDateTime(inputs.u_next_audit_date);
// Extract year and month from the input date
var year = inputDate.getYear();
var month = inputDate.getMonth() + 1; // Months are 0-indexed
// Create a new GlideDateTime for the 1st of the month at 2:00 AM
var newDateTime = new GlideDateTime();
newDateTime.setValue(year + '-' + (month < 10 ? '0' + month : month) + '-01 02:00:00');
// Set the output (use getDisplayValue to return both date and time)
outputs.result_date_time = newDateTime.getDisplayValue();
})(inputs, outputs);
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 05:22 PM - edited 09-17-2024 05:25 PM
I changed the code as mentioned, but I am seeing the same error...
When I test the action - I see the correct Date & Time - the time is being lost when passed back to flow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 05:29 PM
@Lon Landry4 Please check if this post is helpful
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 05:43 PM