cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Creating Recurrence flow for updating column based on number of days

 

  • In the flow, add a condition to check the "Start Date" field:

    • If the "Start Date" is within the first 30 days, set a variable to "Phase1."
    • If the "Start Date" is over 30 days but within 365 days, set the variable to "Phase2."
    • If the "Start Date" is over 365 days, set the variable to "Phase3."
  • Update the SharePoint item's phase column with the value stored in the variable.

  • I have been trying different stuff all day with Conditional Formatting , but then learned it won't automatically update
  • I am lost on the logic here in Powerautomate

thomasw1964_1-1695755953697.png

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

You need to use the field in the Get Items that says Filter Query. Use that to only get items less than or equal 30 days and the phase column does not equal "Phase1".

This way it only gets items that need the Phase1 updated.

 

Look at this link Microsoft Learn In Depth Get Items that explains how the filter query is used in Get Items.

 

To just update the Phase1 items it will look something like this below and use the filter query:

 

StartDate le 'addDays(utcNow(),30)' and PhaseColumn ne 'Phase1'

 

The Get Items looks like below with the filter query above.

Get Items with StartDate less or equals 30 days and Phase Column does not equal Phase1Get Items with StartDate less or equals 30 days and Phase Column does not equal Phase1

 

Then after the update less than 30 day items. You can add another get items that is filtered by between 30 and 365 days. So this will only update the Phase2 items.

The Get Items will use the Filter Query:

 

(StartDate gt 'addDays(utcNow(),30)' and StartDate lt 'addDays(utcNow(),365)') and PhaseColumn ne 'Phase2'

 

In the flow it will look like this below:

Get Items between 30 days and 365 days and update with Phase2Get Items between 30 days and 365 days and update with Phase2

 

After the Phase2 you can add another Get Items that will only update items greater than 365 days and need to be changed to Phase3.

StartDate gt 'addDays(utcNow(),365)' and PhaseColumn ne 'Phase3'

It will look like this below

Get Items greater than 365 days and PhaseColumn not equal to 'Phase3'Get Items greater than 365 days and PhaseColumn not equal to 'Phase3'

 

So basically you have 3 different Get Items that will only get the items within a date range and update them if they have not already had the phase updated.

 

Please review Microsoft Learn In-Depth Get Items that has a great example to reference.

View solution in original post

35 REPLIES 35

How many rows/items do you expect to be in this sharepoint list? 

 

Your plan is not complicated, but it will be doing a lot of duplicate update if you don't do some additional checks. 


For example if you have 30 Items with a StartDate in 30 days.

  • The schedule flow runs today and updates all 30 items to Phase1
  • Tomorrow the schedule flow runs and updates all 30 items to Phase1
  • Thursday the schedule flow runs and updates all 30 items to Phase1

That is a lot of wasted data updating. Also your items will look like they were modified everyday.

FLMike
Multi Super User
Multi Super User

Hello

 

Inside your Apply to Each

1. Create a Compose. Rename it to Get Days

Add this expression, remembering to replace where I have Your Date Column

This calculates the days between today and your date column.

 

int(split(dateDifference(formatDateTime(utcNow(), 'MM-dd-yyyy'), formatDateTime(items()?['Your Date Column']), 'MM-dd-yyyy')),'.')[0])

NOTE: If your Date Column is a String then do this instead
int(split(dateDifference(formatDateTime(utcNow(), 'MM-dd-yyyy'), formatDateTime(DateValue(items()?['Your Date Column'])), 'MM-dd-yyyy')),'.')[0])

 

 

2. Create a second Compose. Rename it to Set Phase

 

 

if(lessOrEquals(outputs('Get_Days'), 30), 'Phase 1', 
   if(and(greaterOrEquals(outputs('Get_Days'), 31),lessOrEquals(outputs('Get_Days'), 365)), 'Phase 2', 'Phase 3')
)

 

 

 

Now the Output of Compose two will be Phase 1 or 2 or 3.

 

But as @wskinnermctc  says you could be updating a lot.

 


Cheers
If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
Thank You
Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
https://gernaeysoftware.com
LinkedIn: https://www.linkedin.com/in/michaelgernaey 

You need to use the field in the Get Items that says Filter Query. Use that to only get items less than or equal 30 days and the phase column does not equal "Phase1".

This way it only gets items that need the Phase1 updated.

 

Look at this link Microsoft Learn In Depth Get Items that explains how the filter query is used in Get Items.

 

To just update the Phase1 items it will look something like this below and use the filter query:

 

StartDate le 'addDays(utcNow(),30)' and PhaseColumn ne 'Phase1'

 

The Get Items looks like below with the filter query above.

Get Items with StartDate less or equals 30 days and Phase Column does not equal Phase1Get Items with StartDate less or equals 30 days and Phase Column does not equal Phase1

 

Then after the update less than 30 day items. You can add another get items that is filtered by between 30 and 365 days. So this will only update the Phase2 items.

The Get Items will use the Filter Query:

 

(StartDate gt 'addDays(utcNow(),30)' and StartDate lt 'addDays(utcNow(),365)') and PhaseColumn ne 'Phase2'

 

In the flow it will look like this below:

Get Items between 30 days and 365 days and update with Phase2Get Items between 30 days and 365 days and update with Phase2

 

After the Phase2 you can add another Get Items that will only update items greater than 365 days and need to be changed to Phase3.

StartDate gt 'addDays(utcNow(),365)' and PhaseColumn ne 'Phase3'

It will look like this below

Get Items greater than 365 days and PhaseColumn not equal to 'Phase3'Get Items greater than 365 days and PhaseColumn not equal to 'Phase3'

 

So basically you have 3 different Get Items that will only get the items within a date range and update them if they have not already had the phase updated.

 

Please review Microsoft Learn In-Depth Get Items that has a great example to reference.

Thank you guys for the assistance,Ii will be trying tomorrow and update this thread , again thanks!

 

Kinda burned out for the day today

This has me the closest but the output on the list came back as

if(lessOrEquals(outputs('Get_Days'), 30), 'Phase 1', if(and(greaterOrEquals(outputs('Get_Days'), 31),lessOrEquals(outputs('Get_Days'), 365)), 'Phase 2', 'Phase 3'))

 

When I use any expression like output() or triggeredoutput() against the output of compose2 the flow fails

I tried many different ways to add the filtering always get a failure on the filtering

thomasw1964_0-1695811911675.png

 

Trying these expressions next

 

concat(slice(outputs('Compose_2'),

add(nthIndexOf(outputs('Compose_2'), ' ', 12), 2),

nthIndexOf(outputs('Compose_2'), ' ', 13)),

substring(outputs('Compose_2'),

add(nthIndexOf(outputs('Compose_2'), ' ', 8), 2), 1))

I see what this did ... ugh it made everyone phase1

Interesting, I did 2 Get Items , the first one checks for Phase1, this allowed me to grab the Dynamic in the second for the Start Date column and do start date le addDays(), 30 and that still fails. I also realized that I need to add client status of Active, as we won't care about updating inactive clients ... we only ever have 160 clients max so I don't think it will be a lot of updating if I filter down to just Active status

Think know why my filters are failing , seems you cannot filter on choice columns or conditional columns

Hi,

 

I don't understand what you mean you cannot use the out put from the second Compose. It would have to be how you are using, not that you cannot use it, works fine for me.

 

Helps to share exactly what you did, not just say it didnt work. Pictures of the flow etc.

Your ask was to make it say Phase 1 or Phase 2 or Phase 3, thats exactly what I provided. What choice are you referring too, you didn't mention that before.

 

And yes you can filter on choices. Is it multiselect, single etc?

 

If you wanted something other than provided, please add details and re-write the ask.


Cheers
If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
Thank You
Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
https://gernaeysoftware.com
LinkedIn: https://www.linkedin.com/in/michaelgernaey

I started with recurrence, added a get items(no filter for testing), created an apply to each, inside of that  I created the 2 compose  the 2 compose and followed up with an Update Item.

PA1.JPGPA2.JPGPA3.JPGPA4.JPGPA5.JPG

@thomasw1964 you need to make it look exactly like the pictures and be sure to include the single ' quotes around the addDays expression. (The only difference should be the column names if you have a different name.)

 

You also need to be sure you are using the correct SharePoint column name within the filter query. Please look at this post about SharePoint Column InternalName and see how to determine what should be used within the filter query. Your column name might be Start_x0020_Date or maybe Start_Date depending on how you initially named it.

 

I really believe the example I showed with the three separate Get Items will be the easiest approach. It only requires that you get the Filter Query working. It uses very basic steps.

 

Please read more about the Get Items and Filter Query here.

HI,

 

It's because you pasted them in as string, and not expressions.

 

Also its Get Days, not Get days for the name, the spelling matters when referencing another Action.

 

Also is this a String or a Choice field? 


Cheers
If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
Thank You
Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
https://gernaeysoftware.com
LinkedIn: https://www.linkedin.com/in/michaelgernaey

@wskinnermctc 

I don't disagree that what you provided works. But if he adds more phases, he will have to keep repeating and adding more sections of the same loop, but with a different filter, versus only updating a single If expression.

 

 

 

 

@FLMike I'm trying to take into account that they don't know how to even write an expression; more less keep updating a complicated one.

If they can figure out how to use a Filter Query first, it can help with making better flows long term or any adjustments. It also simplifies any following steps since all they will have to do is select the choice option in the Update Item step.

 

There should not be an issue with having multiple Get Items if they are only getting the items that needs to be edited. What is less data usage long term? Getting 160 items and updating all of them everyday. Or 3 separate Get Items which may return none, or a couple of items to update?

 

I try to show users what I would do if it was my flow or at least very similar. I would not use an expression with nested if functions that have hard coded references. I don't believe that it is transparent or easily recognized.

 

Plenty of times you can find flows that are difficult to update or correct because so much of the action is happening in some frankenstein expression the last IT person cobbled together just to get the job done. You or I may be able to get in and better recognize issues, but newer users likely won't.

 

IT likes to set things up with the result of if it works, it works. I don't think that is helpful for guiding new users and long term success.

 

Either way, OP seems to be following your example. Hopefully they can figure out how to write the expression.

int(split(dateDifference(formatDateTime(utcNow(), 'MM-dd-yyyy'), formatDateTime(items()?['Your Date Column']), 'MM-dd-yyyy')),'.')[0])

 

This will error when the utcNow() date is the same as the StartDate because there will not be a period '.' in the output. 

You are correct in the fact I am just not getting the expression writing, we will never have more than the 3 phases. But just trying examples of writing the first part of the expression fails for me

 

I have gone back and taken your corrections to my filtering and was missing the '' around the addTime function, I then setup the update item and it ran successfully , but did not put Phase1 in the Phase column

 

I apologize for the lack of knowledge , I've been working with Sharepoint,PowerApps , and Powerautomate for about a month now.. So far I've done OK I think ..Get stuck and eventually get stuff working

 

I changed the filter to look for the ActiveClient eq 'Active'

thomasw1964_0-1695827459506.png

 

I am assuming my issue now is I do not know how to pass Phase1 back to the Phase column

 

thomasw1964_1-1695827525211.png

Thank you for the help so far though I now understand how to write the filters

ClientStatus is filtering, and that would be a good thing as we will only ever have 160 max , we could have a lot more client records for this to look at by going by the phases as we have a pretty good turn over rate on clients not making it through the first 30 days

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Results posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (4,202)