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

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,186)