cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

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

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,633)