- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 03:45 AM
Hi Team,
I'm migrating a workflow to flow designer and not able to move forward with the below step.
Having two variables "Start Date & Time" , "End Date & Time".
In workflow, we find the difference of the two variables and compare them
If the difference > 24 hours, the timer waits for a day prior to the end date and triggers a reminder notification.
How do I compare that 24 hours in flow designer? I'm not able to get greater or lesser or a text field to enter the value.
Can someone help?
I tried it as, if start variable +24 hours using fx function is not end variable, then trigger the notification.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 06:51 AM
update line 4 as this -> don't use getDisplayValue()
var dur = GlideDateTime.subtract(glideStart, glideEnd);
var hour = dur.getByFormat('HH'); //get hour part
if(hour >= 24)
outputs.moreThan24 = true; // no quotes
else
outputs.moreThan24 = false; // no quotes
})(inputs, outputs);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 03:59 AM
Hi,
you need to create custom action for that
1) pass both start and end
2) in that custom action; have script and check if difference is more than 24
3) have output variable of type string
4) then use this custom action and use IF action to check if the diff is more than 24
Custom Action in ServiceNow Flow Designer
(function execute(inputs, outputs) {
var glideFrom = new GlideDateTime(inputs.from);
var glideTo = new GlideDateTime(inputs.to);
var dur = GlideDateTime.subtract(glideFrom, glideTo).getDisplayValue();
var hour = dur.getByFormat('HH'); //get hour part
if(hour >= 24)
outputs.moreThan24 = 'true';
else
outputs.moreThan24 = 'false';
})(inputs, outputs);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 05:15 AM
Thank you! It works! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 05:49 AM
Glad to help.
Please mark response helpful as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 06:41 AM
Its not working for "True" condition, I'm getting undefined if I add a log for HH.