cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
drummer
Helper II
Helper II

Cancel a flow if date changes - Dynamics 365 Sales Order (project start date)

I have a dataverse flow upon Order record creation or change of the Project start date field to send email 2 days before the project start date. When that is later, it waits with delay function.  Sometimes the date may be changed by user which the flow will pick up and start a new flow.
1. How can I cancel the current flow?

Is there a way to cancel the flow after wait period if the date changes (eg. is not equal to the original date when flow started)drummer_0-1667304003816.png

This seems to pull current dates but I have the project start date converted to ISO to compare earlier in flow before the wait.  Can flow keep an original date value and then compare or need to handle differently?

2. Sometimes the date is later than 30 days, I believe it won't wait longer than 30 days is that correct? Any help is appreciated.

5 REPLIES 5
Sundeep_Malik
Community Champion
Community Champion

Hey @drummer 

 

I would suggest to change your approach for the above case.

 

So, what I understood:

You are triggering the flow when a new entry is made in dataverse table or when the date changes?

Am I correct?

 

Instead of this, you should make a scheduled flow, that will run everyday once. It will check if the date current date +2 is equal to the project start date or not. If it is it will send an email for the reminder, if not do nothing.

 

Something like this:

 

Sundeep_Malik_0-1667305735317.png

 

drummer
Helper II
Helper II

@Sundeep_Malik Yes - triggering on create or modify (project date field). I'm getting that feeling not right way. Ty:

Please confirm:
1. can't hold a previous field date
2. Even if so, the run is only for 30 days, I have a project date now that is already 45 days ahead (so schedule is far superior logic)
3. Then I don't even need a delay because it just sends that day. 
Odata style filter is addDays(utcNow(),2) eq crec3_projectstartdate.  We are eastern time zone so do I need to add 5 hours or convert UTC as well?
4. This changes my flow to scheduled correct so is there a way to copy the old flow logic to new? Copy to clipboard or have to copy and recreate it all again...ug

5. New - if let's say the date is updated to a later date and 1st already sent - I think I can add a branch that look as status of e.g. "request submitted" and if so branch a new email to clarify this is revised, check prev. send), etc.

I believe that would do it. Is that optimal from your perspective or any improvement.

 

 

Sundeep_Malik
Community Champion
Community Champion

@drummer

 

1. can't hold a previous field date

 

-> Can you elaborate, didnt get you.

 

2. Even if so, the run is only for 30 days, I have a project date now that is already 45 days ahead (so schedule is far superior logic)

 

-> Yes

 

3. Then I don't even need a delay because it just sends that day.
Odata style filter is addDays(utcNow(),2) eq crec3_projectstartdate. We are eastern time zone so do I need to add 5 hours or convert UTC as well?

 

-> Yup, no need to delay.

Either you can use filter query or after the action use a condition.

Yes, you might have to convert time. For that before get rows action, make a compose and add hours or maybe...

Its just 5 hours and if you are not dealing with time, just the date, then you can schedule the flow at a certain time that the date matches to the utc Date.

 

So lets say, you are 5 hours behind utc. Run the flow at 10am, you can go to advance options and run it at 10 am. So, the time is different but the date would be the same.

 

But if you are dealing with time too, then surely consider converting time.

 

 

4. This changes my flow to scheduled correct so is there a way to copy the old flow logic to new? Copy to clipboard or have to copy and recreate it all again...ug

 

-> You will have to recreate the flow again. You can copy some actions in clipboard, that will work. Though that technique will also not work if you did it a different solution. Or just change the trigger, and add the action get rows, and change some things further in the flow.

 

5. New - if let's say the date is updated to a later date and 1st already sent - I think I can add a branch that look as status of e.g. "request submitted" and if so branch a new email to clarify this is revised, check prev. send), etc.

 

-> Not sure about this part, its your flow, you can think of the logic for this part. But the case would be really rare. Like the reminder will only be sent when utc+2 = project date. Can't think of a logic if reminder is sent and someone changes the date later.

drummer
Helper II
Helper II

Ok perfect. Ty so much. 

So actually it’s subtractFromTime of 2 days. Got it and same logic.

I think I need to move this to a condition vs. filter - we sometimes back date if something was missed or mistake in date after date. So in that the case the filter subtractFromTime for UTC only runs if that date matches and if it's earlier say today Nov 1 and it's backdated to Oct 25 date, it'll never run.

Rather than have users manually change a status, as one way, I think I'll just repurpose my automatic flow to run on date change and if it's before the subtract 2 days, it'll run, otherwise end. 

I'm seeing that I really want to mix automated and scheduled but due to 30 day timeout and id'ing a date change I need to separate these ideas into prior dates (if field is changed). 

Rest got it. I’ll use compose to see how dates are seen by system. 

 

Ty. wow I think I can do this!

drummer
Helper II
Helper II

Condition worked a lot better with a scheduled flow. 
I simply got utcnow - added 2 days and then:
If project start date is < or = to 2 days from now(today) send.
So they send notices 2 days before start date and if someone back dates it just goes on the next schedule. Done! ty
 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (3,343)