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.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Yattering82,

 

Could you please share a screenshot of your flow’s configuration?

I think there is something wrong in your formula that you mentioned above. Please take a try with the following workaround:

  • Choose a proper trigger, here I use Recurrence trigger.
  • Add “Get items” action, specific Site Address and List Name
  • Add “Apply to each”, input parameter set to output of “Get items” action.
  • Within “Apply to each” box, add a Condition, click on “Edit in advanced mode”, type the following formula:

 

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

 

  • Within “If/then” branch, add a “Send an email” action.

Image reference as below:2.JPG

 

3.JPG

 

The flow works successfully as below:4.JPG

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

117 REPLIES 117
brandonklittle
Helper II
Helper II

I'd love to see the solution to this because we have a similar scenario.


Right now we use a SharePoint 2013 WF but we'd like to start replacing those with Microsoft Flows.

 

Our scenario is our purchasing team organizes contracts in a document library and there's a meta tag for expiration notification date and come that date the owner of the document (another tag) and the purchasing department distribution group both receive an email noting the "expiration date" another tag will expire.  This was something a consultant built for us and we've just started to use flow and feel like it's a more simple solution from a support standpoint and modification.

 

Lookign forward to seeing any answers to your question.


Cheers,
Brandon

v-xida-msft
Community Support
Community Support

Hi @Yattering82,

 

Could you please share a screenshot of your flow’s configuration?

I think there is something wrong in your formula that you mentioned above. Please take a try with the following workaround:

  • Choose a proper trigger, here I use Recurrence trigger.
  • Add “Get items” action, specific Site Address and List Name
  • Add “Apply to each”, input parameter set to output of “Get items” action.
  • Within “Apply to each” box, add a Condition, click on “Edit in advanced mode”, type the following formula:

 

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

 

  • Within “If/then” branch, add a “Send an email” action.

Image reference as below:2.JPG

 

3.JPG

 

The flow works successfully as below:4.JPG

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Kris

 

The flow configuration was exactly the same as you mentioned there and I tried many combinations of formula in a vain attempt to determine what I was doing wrong. One of the solutions I tried was very similar to your one with one principal difference - I did not format date and time of the ['nextauditdue'].

 

Your formula works perfectly, thanks very much for your help with this. You have certainly saved me another evening of tweaking and shifting around of expressions.

 

Kind Regards


Yatt

Vicespemas
Regular Visitor

Hi Yattering82,

 

I am reading this thread in which you solved the problem for a flow to send e-mail when date approaches and trying to do the same in my case but, first of all, I cannot get the option "Get Items" when I am creating a flow. Actually, it is not just after the option schedule-reocurrence, but I do not have it shown at all. My options are only: add a do until, add a switch case, add an action, add a condition, apply to each, and add a scope. 

 

Do you know why? Could it be because my version is not up to date? I wasn't thinking of this as being online I thought it all update automatically.

 

My case is similar to this person who asked. Basically, I have a list with a sensor names and I would like to get an e-mail when the calibration date approaches. I also want to apply the workflow to all 40 sensor entries I have an not just when the "item" is created or modified.

 

Could you help me?

 

Many thanks

Hi @v-xida-msft!

 

I have tried this solution in my test enviroment but with your Condition it gives me an error like this: 

 

InvalidTemplate. Unable to process template language expressions for action 'Condition' at line '1' and column '2210': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.

 

As a condition I have used the condition you pasted in your post. 

Hi @v-xida-msft,

 

I am having the same exact issue as @rsaarik is having below. I copy and pasted your Flow, your steps, conditions, everything. 

 

The outputs from Get items seems to return fine (Status Code 200) and I can see the information.

 

Here is my formula for the condition for the Apply to each step:

 

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

 

On the Apply to each step is when things break down:

 

Failed Apply to Each StepFailed Apply to Each Step

I haven't really said what I am trying to do but it's basically identical to the original post. I have a list with one column that has dates that were input manually. I want the Flow to check against today's date + 30 days and if any dates are a match, I want to send an e-mail so we know have something coming up in 30 days.

 

If you got anything I can try that'd be great. Thanks in advance!

 

@rsaarik and @v-xida-msft,

 

I figured out my problem and I think @rsaarik, this will be your problem too. My column name from my SharePoint list is titled "Insurance Expiry Date". So, naturally, I altered @v-xida-msft's code to the following:

 

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

 

And that's the one that's failed. So I looked into the code in Get items step and noticed that the column header was completely different:

Check out the header inside the green box!Check out the header inside the green box!

Yep .. a little different from "Insurance Expiry Date". So I copy pasted the column header from the code and that's how I got my Flow to work perfectly:

 

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

Good luck @rsaarik. Let me know if you can get it working with this!

 

 

Thank you @kristof805 ! The problem was indeed in the list column name. Strangely enough the name in the Flow and name in the SharePoint lists are different. Probably due to some fiddling with column names when I tried to remove those spaces. But now everything works!

From what I've seen from my messing around with Sharepoint lists, that you always have to find your internal column name and use that, instead of the "displayed" column name.

This is a great discussion - I was looking to do the exact thing in our office, with one exception.  Is there a way Flow can ignore the field if there is no date?  In the list I have for this workflow, there are some rows which won't have a date in the column.  My current workflow works, but will result in a failure since not every row has a date in this column.

Hey @sbusby. Sorry for the late reply. I found this little code to work well under the advanced button in the Condition box:

 

@not(empty(triggerBody()?['column name goes here']))

 

If that's confusing, check out this link for some explanation. Good luck!

I have this probblem. I have a flow that is generating notifications when a doc is approaching its consent end date but nevertheless failing. Forgive my ignorance, I'm new at this but where do you add the formula?

flow.png

 

Forgive my ignorance, I'm new at this but where excatly do you add this formula?

@not(empty(triggerBody()?['column name goes here']))

 

I've been working with a flow engineer today but he seems to be flumoxed by this too.

Thank you, Vicki

Hi @Victoria,

 

The code you pointed out is optional and can be used if you have a date colum which is sometimes empty. So your flow can check if the date column is empty. If it is, it can stop. If it is not (you have a date in it), you can move on to check if your date is 30 days away from now or not.

 

As far as your code goes, I think it should be as follows

 

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

Which is what you have. If you can provide the error messages when your flow fails, I can try and help. 

 

 

Hi kristof805,

Thanks for your help.

 

Here's the error message. 

 

InvalidTemplate. Unable to process template language expressions for action 'Condition' at line '1' and column '2482': 'The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#formatdatetime for usage details.'.
 
Thanks, vicki

@Victoria

 

Please see this link. If it doesn't work, it's the 7th post under All Replies on the first page of the thread by me. It has the Get Items box from a failed run that shows what the Flow is getting as inputs and returning as outputs. I'm guessing you'll slightly have to change the column name and your Flow will run. If you can paste a picture on here, like the one I linked in that post, please do.

Hi,

Thanks for your help. 

 

Here is the failure message as an image...

 

I am using Get files (properties only) since I am linking to a doc library. That does seem to be working though. I don't know how to change columns in here because all I am doing is linking to the correct doc library?

 

 

 

I thought it is failing on the apply to each. But my column name is definately correct in here.

 

Cheers, Vicki

 

 

 

 

@Victoria I can't seem to view those images. Did you try attaching them in your message or directly linking them?

Ok sorry, let's try again!

 

flow failure.png

 

 

flow failure2.png

 

Thanks, Vicki

@Victoria

 

My Flow for this expiration e-mail actually uses Get files instead Get files (properties only) as step two. That might help you, if you switch that out.

 

I'm not really sure if grabbing a date from a document library will work in a similar manner. I was grabbing it out of a SharePoint List column. So your Get files (properties only) might be correct.

 

Can you see if you can find the name of your date column in the Body field under the Output? It should look something like Consent End Date. You should be able to see a date on there if things are working properly. Can I get a screenshot of that?

 

 

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 (5,165)