cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Yattering82
New Member

FLOW TO SEND EMAIL WHEN DATE APPROACHES

Hi there

 

This is the first time posting in the forum but a long time user of the forum. What I am trying to do, is to get a flow to trigger an sending an email when the date of a required audit approaches. The audit due dates are listed in a SharePoint list and you would think that this would be a simple thing to do. However, no matter how much I tinker and how much I see what others have done, I cannot get this to work.

 

This is what I have done:

 

@equals(item()?['Nextauditdue'], adddays(utcnow(),'mm-dd-yyyy')+14)

 

So basically I want this to send me an email when it is 14 days to the audit due date. 

 

If anyone can shed light on this, I would be most grateful.

117 REPLIES 117

@Anonymous

 

I think this is going to have to do with the column name.. it's finicky and I think you'll answer will be on page 1 of this discussion. 

 

If you can, check out your Get Items part of your flow on your failed run, specifically where it says Outputs and under that the Body section.

 

You should see your date with your column name in there but if there are spaces or symbols, SharePoint looks at it differently. For example, one column name I have is Insurance Expiry Date but in the Body section where the results are returned, that column is named Insurance_x0020_Expiry_x0020_Dat. And yes, it's just dat and date. I'm guessing there is a character limit there.

 

If we can find this returned column name for you and paste that into your condition, I believe your Flow will run successfully. Also, if nothing is 30 days away from today, you'll get all results back as false, but there won't be any errors.

Anonymous
Not applicable

@kristof805

 

It does not seem to be an issue with getting the items from the list, as in the below image you will see that was done in the flow in 2 seconds. It also shows the corrrect amount of items in the "Apply to each" step, so I feel slightly confident that the data is coming through fine.

 

In the 'Condition', where I have entered the code seems to be where the error message is coming from. It says:

 

InvalidTemplate. Unable to process template language expressions for action 'Condition' at line '1' and column '2532': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'.

 

This is the code I have used:

@equals(formatDateTime(item()?['Expiry Date'], '08/07/2018'), formatDateTime(addDays(utcNow(), 30), '08/07/2018'))

 

I am not sure how to proceed with this.

 

Thanks in advance

 

Capture 22.PNG

@Anonymous

 

Two things:

 

Your code has a specific date in the code. You want something that looks like this:

 

 

@equals(formatDateTime(item()?['Insurance Expiry Date'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), 30), 'MM/dd/yyyy'))

 

Instead of a date, you are telling your flow what format your date that your Get Items step gets will be in. In this, two digits for month, two digits for day and four digits for year, each separated by a forward slash.

 

Secondly, please grab me a screenshot of Body section of the output where it shows the column header and a date. Please make sure to hide any identifiable / private info in said screenshot. You are looking for a column header and a date in the output. Something like this:

 

VendorEmail2.png

Anonymous
Not applicable

@kristof805

 

I have replaced my code with th eone you have mentioned above, only changing your file name for mine. Thanks for explaining everything so well!!

 

I have attached a screenshot of the body section of the flow, but I was not able to find the coloumn name in the same way it was in your screenshot (in red). It is showing all the items from my list on there. I have attached a screenshot which shows the link as best as possible along with the info that is coming under it (with the least amount of hiding I could do.)

 

Thanks in advance.

 

Capture Edit.PNG

@Anonymous

 

I'm glad I was able to explain it in a manner that was easy to understand. Just for my reference, are you using a SharePoint list or a document library as the source for your items? Also, are you using Get items or Get items (properties only)?

 

If you scroll down in the Body, there's lots more data there. Any sign of a date? 

 

I'm not sure why mine is in red / formatted differently. Might be because I'm using Chrome?

Anonymous
Not applicable

@kristof805

 

I am using a SharePoint List as the source for my items. I am using Get Items not the (properties only) one.

 

I found the list name as you had mentioned earlier, which was showing the information I needed but as you had said earlier, the name is very different to the one I have on my list. I have edited it and I got a failure, but no error (screenshot attached). You had mentioned earlier that this would happen if I there were no items that would expire in 30 days.

 

Is this how it is supposed to look if no items expire in 30 days?

 

Capture final hopefully.PNG

@Anonymous

 

That's awesome! I believe now your Flow is working. I would create a bogus / test item on your list that is 30 days away and then trigger your Flow manually to see if you can get an e-mail. If you don't get the e-mail, change the date by a day or two as I don't know if today counts as day 1 or day 0 as far as Flow is concerned. Let me know what happens!

Anonymous
Not applicable

@kristof805

 

I have ben running the flow for a couple of days and I seem to be getting all 60 items on my list as expiring in 2 weeks, every time the flow runs, even though some of them only expire in 2020. I have checked the dates and they are strictly MM/DD/YYYY.

 

I am not sure how I can fix this.

 

Thanks in Advance.

@Anonymous

 

Hey!

 

Can you check if you removed all hardcoded dates from your formula? It sounds like either your expiration date is hard coded (instead of reading the individual dates out of the column) and today is the day that is 60 days away from your formula.

 

Your formula should not contain any actual dates, just formatting info:

 

@equals(formatDateTime(item()?['Insurance Expiry Date'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), 30), 'MM/dd/yyyy'))

So Flow knows how to format the date but there is no actual date like 08/16/2018 in the formula.

Anonymous
Not applicable

@kristof805

 

Hey! Thanks for that!

 

So I was using a @Greaterthanorequal formula instead of @equals whihc seems to have been the problem.

 

But now that I have changed that, I am not getting any notifications, and I have put test results on the list that should hit. I am using 14 days instead of 30 as in the formula you posted, but otherwise it is the same. I have put two test days, one 14 days away and one 15 days away. This is because I did not know if the computer would count today as day 0 or 1.

 

But sadly, the flow says it ran successfull but does not send an email with the item that is exactly 14 days away from expiring.

@Anonymous

 

Maybe, for troubleshooting / narrowing down the problem, you can use the @greaterOrEquals formula for troubleshooting purposes just to figure out if your formula is working at all. You can put 1 or 2 in your days away so anything further than 1 or 2 days away should generate and e-mail for you. 

 

If it doesn't work than something else is wrong.

Anonymous
Not applicable

@kristof805

 

Hey

 

I tried using the @greaterOrEquals formula and did not get any response.

 

@greaterOrEquals(formatDateTime(item()?['OData__x0076_lq3'], 'mm/dd/yyyy'), formatDateTime(addDays(utcNow(), 30), 'mm/dd/yyyy'))

 

I have attached the formula I am using above, I could not find anything wrong with it. Do you see any issues with the code itself? What I mean to get from the code is all the items that expire within the next 30 days from date the flow is run. I am currently getting all the items on the list in the expiration email even though some of them only expire in 2020.

 

 

 

Thanks in advance

@Anonymous

 

Try switching your formula to "@lessOrEquals" and try to do a test run to see what happens.

Anonymous
Not applicable

@kristof805

 

With  "@lessOrEquals", my formula sends me an email with all the items on the list, even though I have specified "14" in the formula.

 

With  "@greaterOrEquals", I recieve no emails in my inbox. I have put test items in my list that expire before this 14 day period.

 

 

So I am either getting all the items or none. I am very confused by this, and I do not have a background in MS Flow or coding so I do not know what is wrong.

@Anonymous

 

Sounds like it's not getting the dates we are trying to feed it. Because if it was, we'd get some e-mails, not all or nothing.

 

I see from a previous post that your current code is as follows:

 

@greaterOrEquals(formatDateTime(item()?['OData__x0076_lq3'], 'mm/dd/yyyy'), formatDateTime(addDays(utcNow(), 30), 'mm/dd/yyyy'))

How did we end up with the OData__x0076_lq3 as our column name? What is your date column called on your SharePoint list? If your data is coming through to the Get items step, we should be able to find the date under the Outputs -> Body section.

 

Here is a test you can do to see if we are getting the data.

  1. Create a test item on your list with the date of 1/1/2049
  2. Run your flow
  3. Check the output and expand the Get items step. Now hit ctrl+f on your keyboard to find text on the webpage. If you type in 2049, it should bring you to the Outputs code where it is returned from your SharePoint list.

Can you take a screen shot for me of where you find the date, while blocking out any sensitive URLs and other data?

 

I'm as confused as you are as I'm not a coder either. I've only started with Flow within the last year and have cobbled together a few Flows which work. It's definitely a learning process but rewarding when you finally get it working.

Anonymous
Not applicable

@kristof805

 

Thats the formula I am using.

 

I got that coloumn name from the body, in the way you have mentioned in this post itself.

 

I have run the test you asked me to above, and the screenshot is attached below. I believe the column name matches what I am using. In this test I used "@greaterOrEquals" and again did not recieve any emails.

 

Capture.PNG

 

Wow, thank you so much for your help!! Really hoping to get the hang of it. Seems like a very powerful tool.

@Anonymous

 

Awesome that you found that. It looks like we ARE getting the dates so that's a plus. Let's try something else. Please change your condition to the following code:

 

 

@equals(formatDateTime(item()?['OData__x0076_lq3'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), 30), 'MM/dd/yyyy'))

 

And change your test item (the 1/1/2049 one) to 9/19/2018. Then run your flow (with the Test button on the top right). Anything? I just did the same thing and I got the e-mail. I tried 9/20/2018 but that did not trigger, so I'm guessing that's 31 days away according to Flow. 

 

Also on your sharepoint list, the column OData__x0076_lq3 (your column that contains the dates) is of type Date and Time, right? I'm pretty sure you've said yes to this before but I wanted to double check.

Anonymous
Not applicable

@kristof805

 

I run multiple tests and I think I am only 1 step away from having it figured out!!

 

So I have replaced my code with the one you have provided in the previous post. This still did not work, but then I realized I have not been using a date AND TIME column! So I have replaced all my dates and kept the standard noon time in all the data points.

 

I tried to run the flow again but now my list contains the wrong column name. How would I find the sharepoint name for the list (e.g. ['OData__x0076_lq3'] ) but without being able to consult the body section of the Get Items tab?

@Anonymous

 

A Date and Time column does not necessarily have to cotain a time (although I think there is a default time when you enter a date .. I can't confirm this).

 

Anyway, the column name should not have changed, unless you specifically edited it. Even if you put into your code the column name as 'pizza', the Flow will still run and your Get Items tab will still get results. The only way Get Items would not get results if you changed your library, site or list name.

 

So even if your stuff in the Apply to each step is broken / giving you errors, your Get Items should still be getting an output. Why do you think your list contains the wrong column name? Did you change it?

Anonymous
Not applicable

@kristof805

 

Yes, I did change the coloumn. The previous one was not Date and Time, as there was no time slot, so I have placed the same information into a time and date coloumn and deleted the older coloumn.

 

So I have the older coloumns name in the my formula, which is probably why it is not working, so I was wondering if you knew how to find the new coloumns name in SharePoint that would be used in the formula?

  

Helpful resources

Announcements

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS   Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!   Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!       Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include 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 image below to find out more!   UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!   European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!     Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!     For more events, click the image below to visit the Microsoft Community Days website.      

Tuesday Tip | Update Your Community Profile Today!

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.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management 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  

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!

Tuesday Tip: Getting Started with Private Messages & Macros

Welcome to 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!   This Week's Tip: Private Messaging & Macros in Power Apps Community   Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member!   Our Knowledge Base article about private messaging and macros is the best place to find out more. Check it out today and discover some key tips and tricks when it comes to messages and macros:   Private Messaging: Learn how to enable private messages in your community profile and ensure you’re connected with other community membersMacros Explained: Discover the convenience of macros—prewritten text snippets that save time when posting in forums or sending private messagesCreating Macros: Follow simple steps to create your own macros for efficient communication within the Power Apps CommunityUsage Guide: Understand how to apply macros in posts and private messages, enhancing your interaction with the Community For detailed instructions and more information, visit the full page in your community today:Power Apps: Enabling Private Messaging & How to Use Macros (Power Apps)Power Automate: Enabling Private Messaging & How to Use Macros (Power Automate)  Copilot Studio: Enabling Private Messaging &How to Use Macros (Copilot Studio) Power Pages: Enabling Private Messaging & How to Use Macros (Power Pages)

Users online (4,599)