cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Stuart6
Regular Visitor

Trying to dynamically change the status of an item

Hi all!

Im new to all this and trying my best not to hassle with questions. I am working on a SharePoint that will track expiry dates on disposable curtains at work. I'm wondering if there is a way to dynamically update the date so that when they become within 30 days it changes it to due soon and emails the relevant people. I hope this makes sense I will attach snippets of what I want.

The email side of things isn't necessary but 100% needs to be updating and changing the SharePoint to due soon and expired so I can keep track.

 

Many Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
creativeopinion
Super User
Super User

@Stuart6 How do you plan on triggering your flow? Will you be running this once a day? Once a week? 

 

Sending an email based on a date is possible—I just uploaded a YT Tutorial on how to do this.

 

I'd recommend running this flow once a day— this way you could easily change the status of an item AND send an email all in one flow. 

Manual Trigger

While building the flow you can insert a manual trigger to make it easy to test the flow and replace this with a Recurrence trigger once the flow is ready to go. 

creativeopinion_0-1695178956947.png

Create a Dynamic Dates

You indicated that you'd like to change dates of items that are within 30 days. In my test list, I've set the Last Changed date for three items to 30 days from today.

creativeopinion_1-1695179084037.png

 

The Scope action is optional—I like to use these in my flow to quickly collapse actions and group them together. I'll be using a few Compose actions to output the dates you'll need to use and compare against in your flow. Tip: Remember to rename your Compose actions to keep things organized.

creativeopinion_3-1695244090333.png

 

 

Add a Convert Time Zone action to convert the current date/time. Depending on when you run the flow—it's always good to convert the date/time to your current timezone.

 

Insert the utcNow() function into the Base Time field. In the Source Time Zone, select (UTC) Coordinated Universal Time. In the Destination time Zone field select your local time zone. In the Format String select Round-trip.

creativeopinion_4-1695179550511.png

Add a Compose action to store the number of days you'd like to add or remove from the current date. In your case you'd like to check for items that will have a due date , 30 days from today. This Compose action isn't necessary—however should you decide to change this to a different number you can easily edit this Compose action rather than having to edit the expression (shown in the next step). 

 

To add days, insert a positive number, to remove days—a negative number.

creativeopinion_6-1695179851100.png

Compose Due Date

Add another Compose action to create the due date (30 days from today). You'll need to insert an expression. Use the addDays() function.

 

The function requires 3 parameters:

addDays([timestamp], [days], [format])

 

creativeopinion_7-1695179981274.png

 

Click on the Dynamic Content tab and insert the Covered time dynamic content from the Convert time zone action.

creativeopinion_8-1695180033031.png

Add a comma and insert the outputs from the Compose action that contains the number of days you'd like to add/remove.

creativeopinion_9-1695180204750.png

Add another comma and insert the date format. I've used 'yyyy-MM-dd'. You can use a different format if you prefer.

creativeopinion_10-1695180239174.png

 

Run a Test. The output of the Compose action should return a date 30 days from today. In my case, it's October 19th.

creativeopinion_11-1695180379804.png

 

Compose Last Changed Date

Since your SP List will only have the Last Changed date, we'll need a way to add 1 year to the date returned from the action above. 

 

Add another Compose action. Use another expression. Except this time, instead of selecting the Converted time dynamic content, select the Output from the Compose action above.

creativeopinion_12-1695180436645.png

Add a comma and -365 (to subtract one year) and the date format. Again, I've used 'yyyy-MM-dd')

creativeopinion_13-1695180477386.png

 

Run a test. The outputs should look like this. Note that the Last Changed Due Date Compose action is a Year prior.

 

creativeopinion_2-1695179494926.png

Get Items

Now that you have your dates, you can use them in the Filter Query of the Get Items action. You'll need to get the Internal Column name for your column. If you aren’t sure how to get this, please refer to this section of one of my YT tutorials.

 

Insert eq for the equals to operator and the outputs from the Compose action with the Last Changed Date.

 

creativeopinion_17-1695180733887.png

This will filter out the items from your SharePoint list that will need to be changed in 30 days. 

 

Add a Compose action to store the number of items returned. Insert an expression. Use the length() function. Insert the value outputs from the Get Items action. 

 

creativeopinion_18-1695180906871.png

 

Run a test! Confirm the number of items returned.

creativeopinion_19-1695180970201.png

Add a Condition

If no items are returned—you can terminate your flow (or leave the NO branch blank). If there are items—add your additional actions into the YES branch.

 

Add an Apply to Each action to loop through each value returned from the Get Items action.

 

Add an Update Item action. You'll need to insert the dynamic content for the ID from the Get Items action and the Title (if this is required field in your list).

 

Next you can insert the Outputs from the Compose action that is storing the due date (aka the date 30 days from today).

creativeopinion_20-1695181009891.png

 

creativeopinion_21-1695181143781.png

 

Select the Due Soon status. 

creativeopinion_22-1695181159804.png

 

Hope this helps!


If I helped you solve your problem—please mark my post as a solution .
Consider giving me a 👍 if you liked my response!

👉Watch my tutorials on YouTube
👉Tips and Tricks on TikTok

View solution in original post

12 REPLIES 12
creativeopinion
Super User
Super User

@Stuart6 How do you plan on triggering your flow? Will you be running this once a day? Once a week? 

 

Sending an email based on a date is possible—I just uploaded a YT Tutorial on how to do this.

 

I'd recommend running this flow once a day— this way you could easily change the status of an item AND send an email all in one flow. 

Manual Trigger

While building the flow you can insert a manual trigger to make it easy to test the flow and replace this with a Recurrence trigger once the flow is ready to go. 

creativeopinion_0-1695178956947.png

Create a Dynamic Dates

You indicated that you'd like to change dates of items that are within 30 days. In my test list, I've set the Last Changed date for three items to 30 days from today.

creativeopinion_1-1695179084037.png

 

The Scope action is optional—I like to use these in my flow to quickly collapse actions and group them together. I'll be using a few Compose actions to output the dates you'll need to use and compare against in your flow. Tip: Remember to rename your Compose actions to keep things organized.

creativeopinion_3-1695244090333.png

 

 

Add a Convert Time Zone action to convert the current date/time. Depending on when you run the flow—it's always good to convert the date/time to your current timezone.

 

Insert the utcNow() function into the Base Time field. In the Source Time Zone, select (UTC) Coordinated Universal Time. In the Destination time Zone field select your local time zone. In the Format String select Round-trip.

creativeopinion_4-1695179550511.png

Add a Compose action to store the number of days you'd like to add or remove from the current date. In your case you'd like to check for items that will have a due date , 30 days from today. This Compose action isn't necessary—however should you decide to change this to a different number you can easily edit this Compose action rather than having to edit the expression (shown in the next step). 

 

To add days, insert a positive number, to remove days—a negative number.

creativeopinion_6-1695179851100.png

Compose Due Date

Add another Compose action to create the due date (30 days from today). You'll need to insert an expression. Use the addDays() function.

 

The function requires 3 parameters:

addDays([timestamp], [days], [format])

 

creativeopinion_7-1695179981274.png

 

Click on the Dynamic Content tab and insert the Covered time dynamic content from the Convert time zone action.

creativeopinion_8-1695180033031.png

Add a comma and insert the outputs from the Compose action that contains the number of days you'd like to add/remove.

creativeopinion_9-1695180204750.png

Add another comma and insert the date format. I've used 'yyyy-MM-dd'. You can use a different format if you prefer.

creativeopinion_10-1695180239174.png

 

Run a Test. The output of the Compose action should return a date 30 days from today. In my case, it's October 19th.

creativeopinion_11-1695180379804.png

 

Compose Last Changed Date

Since your SP List will only have the Last Changed date, we'll need a way to add 1 year to the date returned from the action above. 

 

Add another Compose action. Use another expression. Except this time, instead of selecting the Converted time dynamic content, select the Output from the Compose action above.

creativeopinion_12-1695180436645.png

Add a comma and -365 (to subtract one year) and the date format. Again, I've used 'yyyy-MM-dd')

creativeopinion_13-1695180477386.png

 

Run a test. The outputs should look like this. Note that the Last Changed Due Date Compose action is a Year prior.

 

creativeopinion_2-1695179494926.png

Get Items

Now that you have your dates, you can use them in the Filter Query of the Get Items action. You'll need to get the Internal Column name for your column. If you aren’t sure how to get this, please refer to this section of one of my YT tutorials.

 

Insert eq for the equals to operator and the outputs from the Compose action with the Last Changed Date.

 

creativeopinion_17-1695180733887.png

This will filter out the items from your SharePoint list that will need to be changed in 30 days. 

 

Add a Compose action to store the number of items returned. Insert an expression. Use the length() function. Insert the value outputs from the Get Items action. 

 

creativeopinion_18-1695180906871.png

 

Run a test! Confirm the number of items returned.

creativeopinion_19-1695180970201.png

Add a Condition

If no items are returned—you can terminate your flow (or leave the NO branch blank). If there are items—add your additional actions into the YES branch.

 

Add an Apply to Each action to loop through each value returned from the Get Items action.

 

Add an Update Item action. You'll need to insert the dynamic content for the ID from the Get Items action and the Title (if this is required field in your list).

 

Next you can insert the Outputs from the Compose action that is storing the due date (aka the date 30 days from today).

creativeopinion_20-1695181009891.png

 

creativeopinion_21-1695181143781.png

 

Select the Due Soon status. 

creativeopinion_22-1695181159804.png

 

Hope this helps!


If I helped you solve your problem—please mark my post as a solution .
Consider giving me a 👍 if you liked my response!

👉Watch my tutorials on YouTube
👉Tips and Tricks on TikTok
FLMike
Multi Super User
Multi Super User

Hi,

 

You would want to do the following:

Step 1: Create a reoccurring flow. I have this one set to run every day at 7AM

FLMike_0-1695177102440.png

 

Step 2: Get Items Action from SharePoint List

 You can use a filter if you need to retrieve less records, based on whatever you want

FLMike_1-1695177161966.png

 

Step 3: Use an Apply to Each Action to loop through all the items returned from Get Items

You get the list by using the Dynamic property value (don't use body)

Next, click the ... at the end of the Header of Apply to Each

-Click Settings

-Turn on Concurrency

-Set to 1

-Close

FLMike_2-1695177240549.png

 

Step 4: Ok, now you said you want to track how close something gets to 30 days.

So IN the loop, you first want to calculate the datedifference between the Due Date column of this row in the loop and today's Date. 

FLMike_3-1695177794287.png

 

So add a Compose method instead of the loop and add this formula. The formula uses the datedifference function that returns a string that looks like this d.hh:mm:ss.fffffff where d equals days. We want the d part, not the whole thing.

 

So first we get that string value and then we parse the string to ONLY get the d value and then convert it to an int.

 

int(split(dateDifference(utcNow(), addDays(utcNow(),5)),'.')[0])

 

The above function needs you to replace the utcNow() with the Date column in the loop and the addDays(utcNow(),5) needs to change to utcNow(). 


My example function fakes the dates by taking today as if it was the Due date and then takes today and adds 5 days. Again just replace them with your stuff

 

Step 5: Ok now that you have that number you have to decide what you want to do with it. I dont know how many days it takes before it changes to some other value.

 

But let's Pretend that the result was a perfect number and you knew that if it it was30 days before the due date, 21 days before, 14 days before and 7 days before

equals 30 Set X 

equals 21 set W

equals 14 set Y

equals 7 set X

 

We can use a switch statement IN the loop right after the Compose action which I renamed "Get Days Before Due Date" and now the switch statement has 5 paths, 30,21,14,7 Or default, which would be ANY number that isn't one of these and you DONT need to change the value

FLMike_4-1695178244222.png

 

Note: I am showing the switch to make it easier. You could write a complex Compose that would have a function that would calculate the days and return back the choice value, but I didn't want to do that to you right now.

 

Step 6:

a) Put an Update Item in the 30 day branch

b) Put an Update Item in the 21 day branch

c) Put an Update Item in the 14 day branch

d) put an Update Item in the 7 day branch

e) in the Default do nothing

FLMike_5-1695178528319.png

 

Now in the Update Item action (in each branch) set it to the proper value in the Choice field you have in your picture. You get the ID of the Item from the Apply to Each loop. You only need to have the ID and your choice value.

 

Step 7: I am not sure which ones you want to send email for (in my example 7,14,21,30) but you would add a Send Email V2 action to which ever ones you want.

 

And now you have a way to monitor the due date versus current date. please let me know if I missed anything.
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

This is amazing!!

With the due date column I have already made a calculated column for it to update the date depending on the last changed date. 

 

How would I make the last changed date be the calculated column to allow the due date to be used for the update item in the flow? 

 

Sorry I hope this makes sense 

 

 
 
I have attached the formula the formula i had used for the calculated due date
 
Many Thanks you are my hero!

@Stuart6 I'm a bit unclear on what your requirement is. Based on the screenshots you originally provided an item was marked Overdue. I would assume that the Last Changed date needs to be manually inputted and not automatically changed. 

 

I was unaware that you were using a calculated column for the due date. If this is the case, then I believe the requirement would be to change the status of the items returned to due soon. 

 

What you would need to do is probably add an additional argument in your Filter Query to return items with dates that are overdue (and are not marked as overdue)—is that what you are looking for?

Yeah sorry, maybe abit of background might of helped. It's for the hospital I work at, my plan is to input the dates manually in the date changed when the disposable curtains are replaced. The calculated column was put it so I only had to enter one date and then select the 6 or 12 months. For it to work how you laid out would I need to revert the due date column to normal, then maybe make the date changed column be the calculated one to populate the correct dates for the 6 or 12 months? 

 

I'm hoping I can work it that I can enter a date when the curtains are changed and it the populate the due date. Which would then go onto the amazing flow to alert when 30 days Due Soon and then Over Due..

 

Thank you so much so far awesome help!!

@Stuart6 I should clarify what I meant in my earlier response. I was unaware that you had a calculated date column for the due date. Because you do—that column will be automatically updated whenever you change the date in the Last Changed column (which is done manually — as you have indicated).

 

In the Update Item action, you can leave the due date field blank (since it's a calculated column) and just change the Status to Due Soon (which is what you wanted to accomplish from your original ask.. ). 

 

Let me know if I've missed something. If you'd like the automation to calculate the due date for you instead, then you can adjust the automation to do that. It's up to you. The only challenge with a calculated column is that you cannot filter on that column in the Get Items action. 

 

Not sure how you want to alert (via Teams, Email or both) and who you want to alert. Do you have a column in your SP list that indicates who needs to be alerted? 

To check if any items are overdue. You would need to adjust your Filter Query a bit to capture items that are Due Soon as well as Overdue and then to alert. What will the logic be for overdue items? You want to notify the day after a due date or wait a few days. You'll need to figure out that logic before you can build out the rest of your flow. 

Ahh, I see! OK so if it is simple enough and maybe helps in the future how can we make the automation add the due date? That might be better! yeah I have a responsible person column which I would just populate through my Teams.

 

The idea is that supervisors will be checking SharePoint with the view options to filter the Due Soon and Overdue, so once it's automated to change the status the rest can be monitored I believe. Then hopefully just need the date changed updated when they have been replaced.

 

I cant thank you enough so far you have been amazing!

Stuart6
Regular Visitor

So that has got it working for the status to change to Due Soon,, What do I have to do to add in it going to Overdue once it has passed today's date?

 

the Logic for the Overdue should just be going Red and the status change, would I need to add something in the scope for this to be flagged?

@Stuart6 What I mean by logic is at what point (how many days past the due date) would an item be considered overdue?

 

There needs to be logic built in your flow so you can trigger the right actions at the right time. Hope the clarifies things.

yeah sure, any thing past the current date would be considered overdue, so 30 days for due soon , an -1 for overdue

@Stuart6 There are a few ways you could automate adding a due date. Depends in your workflow. Is it typical for multiple items to be updated at once with a Last Changed Date? Or one item at a time? You could have a single flow run once a day to check the list and make appropriate adjustments. 

 

Alternatively you could have another flow that will set the Last Changed date to the current date while automatically updating the Due Date column with a manual trigger. 

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (5,344)