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

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. 

 

 

 

Where the Counter goes within Main FlowWhere the Counter goes within Main Flow

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

High Level View of Counter ProcessHigh Level View of Counter Process

Where the counter is "Made"Where 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
Brad_Groux
Community Champion
Community Champion

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
Brad_Groux
Community Champion
Community Champion

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

Hello @Brad_Groux ,

 

Thank you for the helpful links I appreciate it! 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,536)