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

Exclusive LIVE Community Event: Power Apps Copilot Coffee Chat with Copilot Studio Product Team

It's time for the SECOND Power Apps Copilot Coffee Chat featuring the Copilot Studio product team, which will be held LIVE on April 3, 2024 at 9:30 AM Pacific Daylight Time (PDT).     This is an incredible opportunity to connect with members of the Copilot Studio product team and ask them anything about Copilot Studio. We'll share our special guests with you shortly--but we want to encourage to mark your calendars now because you will not want to miss the conversation.   This live event will give you the unique opportunity to learn more about Copilot Studio plans, where we’ll focus, and get insight into upcoming features. We’re looking forward to hearing from the community, so bring your questions!   TO GET ACCESS TO THIS EXCLUSIVE AMA: Kudo this post to reserve your spot! Reserve your spot now by kudoing this post.  Reservations will be prioritized on when your kudo for the post comes through, so don't wait! Click that "kudo button" today.   Invitations will be sent on April 2nd.Users posting Kudos after April 2nd at 9AM PDT may not receive an invitation but will be able to view the session online after conclusion of the event. Give your "kudo" today and mark your calendars for April 3, 2024 at 9:30 AM PDT and join us for an engaging and informative session!

Tuesday Tip: Unlocking Community Achievements and Earning Badges

TUESDAY TIPS are our way of communicating 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! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!     THIS WEEK'S TIP: Unlocking Achievements and Earning BadgesAcross the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. These badges each signify a different achievement--and all of those achievements are available to any Community member! If you're a seasoned pro or just getting started, you too can earn badges for the great work you do. Check out some details on Community badges below--and find out more in the detailed link at the end of the article!       A Diverse Range of Badges to Collect The badges you can earn in the Community cover a wide array of activities, including: Kudos Received: Acknowledges the number of times a user’s post has been appreciated with a “Kudo.”Kudos Given: Highlights the user’s generosity in recognizing others’ contributions.Topics Created: Tracks the number of discussions initiated by a user.Solutions Provided: Celebrates the instances where a user’s response is marked as the correct solution.Reply: Counts the number of times a user has engaged with community discussions.Blog Contributor: Honors those who contribute valuable content and are invited to write for the community blog.       A Community Evolving Together Badges are not only a great way to recognize outstanding contributions of our amazing Community members--they are also a way to continue fostering a collaborative and supportive environment. As you continue to share your knowledge and assist each other these badges serve as a visual representation of your valuable contributions.   Find out more about badges in these Community Support pages in each Community: All About Community Badges - Power Apps CommunityAll About Community Badges - Power Automate CommunityAll About Community Badges - Copilot Studio CommunityAll About Community Badges - Power Pages Community

Tuesday Tips: Powering Up Your Community Profile

TUESDAY TIPS are our way of communicating 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! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!   This Week's Tip: Power Up Your Profile!  🚀 It's where every Community member gets their start, and it's essential that you keep it updated! Your Community User Profile is how you're able to get messages, post solutions, ask questions--and as you rank up, it's where your badges will appear and how you'll be known when you start blogging in the Community Blog. Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile.     Password Puzzles? No Problem! Find out how to sync your Azure AD password with your community account, ensuring a seamless sign-in. No separate passwords to remember! Job Jumps & Email Swaps Changed jobs? Got a new email? Fear not! You'll find out how to link your shiny new email to your existing community account, keeping your contributions and connections intact. Username Uncertainties Unraveled Picking the perfect username is crucial--and sometimes the original choice you signed up with doesn't fit as well as you may have thought. There's a quick way to request an update here--but remember, your username is your community identity, so choose wisely. "Need Admin Approval" Warning Window? If you see this error message while using the community, don't worry. A simple process will help you get where you need to go. If you still need assistance, find out how to contact your Community Support team. Whatever you're looking for, when it comes to your profile, the Community Account Support Knowledge Base article is your treasure trove of tips as you navigate the nuances of your Community Profile. It’s the ultimate resource for keeping your digital identity in tip-top shape while engaging with the Power Platform Community. So, dive in and power up your profile today!  💪🚀   Community Account Support | Power Apps Community Account Support | Power AutomateCommunity Account Support | Copilot Studio  Community Account Support | Power Pages

Super User of the Month | Chris Piasecki

In our 2nd installment of this new ongoing feature in the Community, we're thrilled to announce that Chris Piasecki is our Super User of the Month for March 2024. If you've been in the Community for a while, we're sure you've seen a comment or marked one of Chris' helpful tips as a solution--he's been a Super User for SEVEN consecutive seasons!   Since authoring his first reply in April 2020 to his most recent achievement organizing the Canadian Power Platform Summit this month, Chris has helped countless Community members with his insights and expertise. In addition to being a Super User, Chris is also a User Group leader, Microsoft MVP, and a featured speaker at the Microsoft Power Platform Conference. His contributions to the new SUIT program, along with his joyous personality and willingness to jump in and help so many members has made Chris a fixture in the Power Platform Community.   When Chris isn't authoring solutions or organizing events, he's actively leading Piasecki Consulting, specializing in solution architecture, integration, DevOps, and more--helping clients discover how to strategize and implement Microsoft's technology platforms. We are grateful for Chris' insightful help in the Community and look forward to even more amazing milestones as he continues to assist so many with his great tips, solutions--always with a smile and a great sense of humor.You can find Chris in the Community and on LinkedIn. Thanks for being such a SUPER user, Chris! 💪 🌠  

Tuesday Tips: Community Ranks and YOU

TUESDAY TIPS are our way of communicating 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! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!This Week: Community Ranks--Moving from "Member" to "Community Champion"   Have you ever wondered how your fellow community members ascend the ranks within our community? What sets apart an Advocate from a Helper, or a Solution Sage from a Community Champion? In today’s #TuesdayTip, we’re unveiling the secrets and sharing tips to help YOU elevate your ranking—and why it matters to our vibrant communities. Community ranks serve as a window into a member’s role and activity. They celebrate your accomplishments and reveal whether someone has been actively contributing and assisting others. For instance, a Super User is someone who has been exceptionally helpful and engaged. Some ranks even come with special permissions, especially those related to community management. As you actively participate—whether by creating new topics, providing solutions, or earning kudos—your rank can climb. Each time you achieve a new rank, you’ll receive an email notification. Look out for the icon and rank name displayed next to your username—it’s a badge of honor! Fun fact: Your Community Engagement Team keeps an eye on these ranks, recognizing the most passionate and active community members. So shine brightly with valuable content, and you might just earn well-deserved recognition! Where can you see someone’s rank? When viewing a post, you’ll find a member’s rank to the left of their name.Click on a username to explore their profile, where their rank is prominently displayed. What about the ranks themselves? New members start as New Members, progressing to Regular Visitors, and then Frequent Visitors.Beyond that, we have a categorized system: Kudo Ranks: Earned through kudos (teal icons).Post Ranks: Based on your posts (purple icons).Solution Ranks: Reflecting your solutions (green icons).Combo Ranks: These orange icons combine kudos, solutions, and posts. The top ranks have unique names, making your journey even more exciting! So dive in, collect those kudos, share solutions, and let’s see how high you can rank!  🌟 🚀   Check out the Using the Community boards in each of the communities for more helpful information!  Power Apps, Power Automate, Copilot Studio & Power Pages

Find Out What Makes Super Users So Super

We know many of you visit the Power Platform Communities to ask questions and receive answers. But do you know that many of our best answers and solutions come from Community members who are super active, helping anyone who needs a little help getting unstuck with Business Applications products? We call these dedicated Community members Super Users because they are the real heroes in the Community, willing to jump in whenever they can to help! Maybe you've encountered them yourself and they've solved some of your biggest questions. Have you ever wondered, "Why?"We interviewed several of our Super Users to understand what drives them to help in the Community--and discover the difference it has made in their lives as well! Take a look in our gallery today: What Motivates a Super User? - Power Platform Community (microsoft.com)

Users online (3,837)