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. 

 

 

 

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 Helper II
Helper II

Re: Creating a Date Counter

Hello @Brad_Groux ,

 

Thank you for the helpful links I appreciate it! 

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (9,051)