cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Barber_Chris
Level: Powered On

Static Date For Condition

Hi,

I have created a flow that checks dates in a sharepoint list to the current date and if the date is a match at starts an approval to send a follow up email. 

 

The flow runs every morning at 9am and i have got it all working perfect. The only issue i have is that if the flow runs on a weekend when no one can approve the follow up until a monday morning the first approval get approved on the monday morning but the next item in the list gets missed because the condition checks the date against the new monday date. 

 

I therefore need the date to on the expression to be static. 

 

If anyone could help it would be greatly appreciated. 

 

Here is my flow and the axpression im using is 

formatDateTime(utcNow(), 'yyyy-MM-dd')

 

Regards,

Capture101.PNG

7 REPLIES 7
Super User
Super User

Re: Static Date For Condition

@Barber_Chris :

 

Can you tell me how the 1st Follow-up date is set?   You might consider leaving your Flow unchanged and setting the first follow-up date to the following Monday.  The DayOfWeek() and AddDays() expressions will be very helpful to you should you want to set this date via a Flow.

 

As an aside, you may want to using an OData filter in your Get items expression rather than using a condition.  Using the filter will mean that only items with a 1st follow up date of today will be returned.  Your Flow will run faster and using the filter will help you avoid the limits of how many items can be retrieved from a SharePoint list.

 

OData filters use a columns internal name.  If your column name is 1 Follow Up then the OData filter (filter query) will look something like this:

_x0031_st_x0020_Follow_x0020_Up eq 'expression'

The expression will be the same:  formatDateTime(utcNow(), 'yyyy-MM-dd')

 

If you need additional help. please post here.

 

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Highlighted
Piper
Level 8

Re: Static Date For Condition

@Barber_Chris in addition to what @ScottShearer said within that OData you can build a more complex condition using the functions @ScottShearer  referenced. Also, don't bother executing the Get Items if CurrentDate is Saturday or Sunday.

 

Here's some psuedo code for you for the Get Items filter:

 

(

     YourDate eq CurrentDate

or

     (

          dayOfWeek(CurrentDate) eq 1 (Monday)

     and

          (

              YourDate eq addDays(CurrentDate, -2) --Saturday

           or

               YourDate eq addDays(CurrentDate, -1) --Sunday

         )

      )

)

 

Best of luck to you,

Piper

Barber_Chris
Level: Powered On

Re: Static Date For Condition

Hi Scott

The first follow up date is in a sharepoint list colum. There is a few hundered items in the list and this grows weekly as there are all quote's we have sent to clients.

 

The OData filter sounds great but im relatively new to flow with limited programing knowledge so im not sure how easy this would be for me. Do you have any further info on how i would set this up?

 

Regards,

Chris

Super User
Super User

Re: Static Date For Condition

@Barber_Chris :

 

After looking at your Flow again, I just realized that you have another issue that will require you to re-write your Flow.  The issue is that with a standard approval, the Flow pauses until the approval is complete.  You have your approval inside of a loop.  Therefore, the Flow will pause on each approval until it is complete before it sends the next approval.

 

There are a number of ways to work around this issue.  Before I propose a solution, can you tell me how the 1st follow-up date is calculated?  Is it based on when the item is created?  How far from the created date is the first follow-up date?

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Barber_Chris
Level: Powered On

Re: Static Date For Condition

Hi Scott
Thanks for your response.
Yes the approval does indeed do that. It’s a bit of a pain but I was willing to live with it. If they could all be sent at the same time that would be perfect if you know of a better solution.

So the 1st follow up date is created by a separate flow whereby when a planner task is completed to say the quote has been sent it creates a follow up date in SharePoint 3 weeks from the task complete date.

I hope that makes sense.

Regards
Chris
Super User
Super User

Re: Static Date For Condition

@Barber_Chris :

Thanks for the follow-up.

I believe that your solution is going to involve using the new "Create and Approval(V2)" action.  This action does not wait for action to be taken on an approval before moving on.  You'll need to loop through each approval that was started after the approval actions loop in order to take action when the items are approved or rejected.  The Flow design needs some thought.

Also, can you tell me why you don't run the Flow every day?  That way, nothing will be missed and you won't need to complicate the Flow with logic to account for weekends.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Barber_Chris
Level: Powered On

Re: Static Date For Condition

Hi Scott,

Ok can i just change the "start an approval" to "Create an Approval (V2)"?

 

The flow does run everyday at 9am. but on a weekend there is no one to approve the flow so it sits there all weekend until monday morning and then the date has changed and no longer matched the ones which needed to run on a saturday and sunday date.

 

Regards,

Chris

Helpful resources

Announcements
firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,288)