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

Creating a Date Counter

Hello,

 

For my approval flow route, I have a field to monitor how long the approval route has been open in number of days. I can calculate this based off of when each approval was completed but I have a reminder loop/ branch that will send a reminder email to each approver if they haven't approved the file within a certain time frame. 

 

Within this branch, I have a do until to do a check if the approvals have been done every 15 minutes and during this loop, I need to update the number of days open. 

 

My thought on this is that if it's the start of a new day and the time now are equal or within 15 minutes after the start of a new day, I would increase a variable by 1 and calculate it the days open variable that way. The way I have this working is not the simplest so I'm asking for help in coming up with a better way to do it. I've attached screenshots of my flow along with the lines of code used. I would like this to be as simple as possible since the flow it's going in is large and it has be be used at each level of approvers (up to 4 levels at times). This variable has to count correctly up to the end of the flow. 

 

 

Compose: 

formatDateTime(addHours(startofDay(addDays(convertFromUtc(utcNow(),'Eastern Standard Time'),1)),9),'u')

Do Until: 

@greaterOrEquals(formatDateTime(convertFromUtc(utcNow(), 'Eastern Standard Time'), 'u'), outputs('Compose'))

Within the Do Until: 

Compose 3: 

startOfDay(convertFromUtc(utcNow(),'Eastern Standard Time'),'u')

Condition: 

@equals(formatDateTime(convertFromUtc(utcNow(), 'Eastern Standard Time'), 'HH'),formatDateTime(outputs('Compose_3'),'HH'))

Within the Condtion under the yes branch:

Compose 8:

sub(int(formatDateTime(convertFromUtc(utcNow(), 'Eastern Standard Time'), 'mm')),int(formatDateTime(outputs('Compose_3'),'mm')))

Condition 2: 

@lessOrEquals(outputs('Compose_8'),15)

Under the Yes Branch is where x is increased by 1 (which is my date counter) and the SharePoint Item gest updated with this. Under both no branches of the conditions nothing would happen, so as a placeholder for now is another variable getting increased if that path is chosen. At the end there's a 15 minute delay until next check. All of these are within the Do Until. 

 

 

 

overview.PNGWhere the Counter goes within Main Flow

This date counter will go into the action Do Until 5 with the Delay 8 action. 

test component.PNGHigh Level View of Counter Process

making the counter.PNGWhere the counter is "Made"

 

 I know this is really long and while this solution works I was hoping someone could help me make it simpler. Or suggest a better way at achieving what I'm looking for. I have to implement this process into the flow in multiple spots within multiple flows so the similar the better. 

 

Thank you very much. I appreciate any help given and/ or feedback. 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Creating a Date Counter

From what I can see, you've actually written a fairly solid Flow for what you are trying to achieve. As you are incrementing a count, it is inherently going to be fairly unwieldy. One option that you may want to consider, is utilizing parallel branches if and when possible. Example:FormsCreateTaskParallelBucket.PNG

Also to improve overall performance, you may want to consider offloading some of the heavy lifting to Azure Functions, and then calling the Function from Flow. See Extending Flow with Functions, Part 1 and Part 2

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Creating a Date Counter

From what I can see, you've actually written a fairly solid Flow for what you are trying to achieve. As you are incrementing a count, it is inherently going to be fairly unwieldy. One option that you may want to consider, is utilizing parallel branches if and when possible. Example:FormsCreateTaskParallelBucket.PNG

Also to improve overall performance, you may want to consider offloading some of the heavy lifting to Azure Functions, and then calling the Function from Flow. See Extending Flow with Functions, Part 1 and Part 2

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Highlighted
leanns
Level: Powered On

Re: Creating a Date Counter

Hello @Brad_Groux ,

 

Thank you for the helpful links I appreciate it! 

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

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 (5,510)