Execute Timer based on difference of two dates in Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 03:07 AM
Hi All,
I have a form for a catalog item which has two dates start and end , and based on the difference of these two dates I need to execute a timer in flow designer.
Where do I need to calculate the difference of these two dates like where will I write the script and then how to run a timer ?
Thanks in advance.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 03:24 AM
Hi @Anubhav24 , we have a "Wait For" functionality in flow designer where you can set custom duration to wait.
Please refer the below documentation for better understanding.
I would appreciate if you can mark this response as correct or helpful if it helped you with your question.
Thanks,
Aryan Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 04:33 AM
Hi @Anubhav24 ,
You can achieve this with the below logic. But I'm not sure, how comfortable you are in creating a new variable.
1. Create a variable in the catalog item, which stores the difference between start and end. (Populate the different using onChange client script).
2. In Flow designer, retrieve duration value using Get Catalog variables action.
3. Add Wait for duration flow logic, pass the value of duration using the Data Picker.
If you are not comfortable in creating variable, you can make use of g_scartchpad to do so. But g_scratchpad will be more complex.
Regards,
Dhanraj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 04:41 AM
Creating another variable is fine but is there some approach in flow designer to do this , like adding a custom script action and then calculating the value of the date difference and then use that value but again that would be in a variable which will not be available as a data to be provided to wait for condition ? Correct me if I am wrong here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 05:15 AM
Ummmm!! If you are approaching this way, still you can be able to pass the value to Wait for a duration flow logic. But the value being passed into that flow logic should be Duration Type. Something like in below picture.
var startDate = new GlideDateTime('2024-09-08 09:00:00');
var endDate = new GlideDateTime('2024-09-09 10:00:00');
var diff = GlideDateTime.subtract(startDate,endDate);
Assign the value of "Diff" to the duration and directly assign the output to the flow logic. I'm pretty this works. But I'm just curious to know about making the flow wait for a long durations. Won't it affect the perfomance.
Regards,
Dhanraj.