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

Tuesday Tips: Getting Started in the Community

TUESDAY TIPS is back!   This weekly series of posts is our way of sharing helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! The original run of Tuesday Tips was a highlight of last year, and these all-new Tips will hopefully prove to be just as informative as helpful. We will cover some basics about the Community, a few "insider tips" to make your experience even better, and sharing best practices gleaned from our most active community members and Super Users. Make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!   THIS WEEK: I'm Brand New! What Do I Do? The number of new community members we have each week is pretty amazing, and we are so glad to welcome all of you to the Community! You may be wondering. "What do I do? Where do I get started? Will anyone be willing to help me? What I have a question? Help!"   Let's start with this: Welcome to the low-code revolution, and more importantly, welcome to the Power Platform Community! This is a great place to start. Whether you're busy with Power Apps, getting familiar with Power Automate, engaging Copilot Studio, or building in Power Pages, there are a few key places you should check out as you begin your journey: FORUMS: The forums are THE place to ask questions, look at questions asked by other Community members—and see answers and solutions from our Super Users and other helpful people in the Community. Power Apps ForumsPower Automate ForumsCopilot Studio ForumsPower Pages Forums   NEWS & ANNOUNCEMENTS: Our News & Announcements section highlights the newest and greatest updates in the Community, news from the product team, and so much more. It’s updated a few times each week and will also help you find ways to connect with what’s going on in the ever-growing world of Power Platform. Power Apps News & AnnouncementsPower Automate News & AnnouncementsCopilot Studio News & AnnouncementsPower Pages News & Announcements   GALLERIES: The Galleries section of the Community features tons of tips and tricks, features and benefits, and more—through videos created by our Super Users, product teams, and other helpful members of the Community. Power Apps GalleriesPower Automate Galleries Copilot Studio GalleriesPower Pages Galleries BLOGS: The community blogs section is full of handy step-by-step tips from members of the Community—and some of them include detailed answers to some of the questions most frequently asked questions, as well as how they solved a problem they faced. Power Apps Community BlogPower Automate Community BlogCopilot Studio Community BlogPower Pages Community Blog POWER UP PROGRAM: If you’d like to really take a huge step forward in your journey, we recommend checking out the Power Up Program, a Microsoft-sponsored initiative that trains new Power Platform users and has been a huge success since it launched a little over a year ago. There’s a waiting list, so definitely apply soon if you’re interested! Find out more here: Microsoft Power Up Program for career switchers.   There's so much more you'll discover in your Power Platform experience, and this Community is here for YOU! We are glad you've discovered us and can't wait to see where you grow! If you're new to the Community and just getting started, make sure to give this post a kudo and introduce yourself so we can welcome you!

Super User of the Month | Drew Poggemann

As part of a new monthly feature in the Community, we are excited to share that Drew Poggemann is our featured Super User for the month of February 2024. If you've been in the Community for a while, we're sure Drew's name is familiar to you, as he is one of our most active contributors--he's been a Super User for five consecutive seasons!   Since authoring his first reply 5 years ago to his 514th solution authored, Drew has helped countless Community members with his insights and expertise. In addition to being a Super User, Drew is also a User Group leader and a Microsoft MVP. His contributions to our Super User sessions and to the new SUIT program are always welcome--as well as his sense of humor and fun-loving way of sharing what he knows with others.   When Drew is not solving problems and authoring solutions, he's busy overseeing the Solution Architecture team at HBS, specializing in application architecture and business solution strategy--something he's been doing for over 30 years. We are grateful for Drew and the amazing way he has used his talent and skills to help so many others in the Community. If you are part of the SUIT program, you got to hear some great tips from Drew at the first SUIT session--and we know he still has much more to share!You can find him in the Community and on LinkedIn. Thank you for all you do, Drew!

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. Our team will be reviewing posts using the new "Copilot Studio" label to ensure we highlight and amplify the most relevant and recent content, so you're assured of high-quality content every time you visit. If you share a post that gets featured in the curated gallery, you'll get a PM in the Community to let you know!The curated gallery is ready for you to experience now, so visit the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community. We can't wait to see what you "cook" up!    

Celebrating a New Season of Super Users with Charles Lamanna, CVP Microsoft Business Applications

February 8 was the kickoff to the 2024 Season One Super User program for Power Platform Communities, and we are thrilled to welcome back so many returning Super Users--as well as so many brand new Super Users who started their journey last fall. Our Community Super Users are the true heroes, answering questions, providing solutions, filtering spam, and so much more. The impact they make on the Communities each day is significant, and we wanted to do something special to welcome them at our first kickoff meeting of the year.   Charles Lamanna, Microsoft CVP of Business Applications, has stressed frequently how valuable our Community is to the growth and potential of Power Platform, and we are honored to share this message from him to our 2024 Season One Super Users--as well as anyone who might be interested in joining this elite group of Community members.     If you want to know more about Super Users, check out these posts for more information today:    Power Apps: What is A Super User? - Power Platform CommunityPower Automate: What is A Super User? - Power Platform Community Copilot Studio: What is A Super User? - Power Platform Community Power Pages: What is A Super User? - Power Platform Community

Super Users 2024 Season One is Here!

   We are excited to announce the first season of our 2024 Super Users is here! Our kickoff to the new year welcomes many returning Super Users and several new faces, and it's always exciting to see the impact these incredible individuals will have on the Community in 2024! We are so grateful for the daily difference they make in the Community already and know they will keep staying engaged and excited for all that will happen this year.   How to Spot a Super User in the Community:Have you ever written a post or asked for help in the Community and had it answered by a user with the Super User icon next to their name? It means you have found the actual, real-life superheroes of the Power Platform Community! Super Users are our heroes because of the way they consistently make a difference in the Community. Our amazing Super Users help keep the Community a safe place by flagging spam and letting the Community Managers know about issues. They also make the Community a great place to find answers, because they are often the first to offer solutions and get clarity on questions. Finally, Super Users share valuable insights on ways to keep the Community growing, engaging, and looking ahead!We are honored to reveal the new badges for this season of Super Users! Congratulations to all the new and returning Super Users!     To better answer the question "What is a Super User?" please check out this article: Power Apps: What is A Super User? - Power Platform CommunityPower Automate: What is A Super User? - Power Platform Community Copilot Studio: What is A Super User? - Power Platform Community Power Pages: What is A Super User? - Power Platform Community

Microsoft Power Platform | 2024 Release Wave 1 Plan

Check out the latest Microsoft Power Platform release plans for 2024!   We have a whole host of exciting new features to help you be more productive, enhance delegation, run automated testing, build responsive pages, and so much more.    Click the links below to see not only our forthcoming releases, but to also try out some of the new features that have recently been released to market across:     Power Apps  Power Automate  Copilot Studio   We can’t wait to share with you all the upcoming releases that will help take your Power Platform experience to the next level!    Check out the entire Release Wave: Power Platform Complete Release Planner 

Users online (4,879)