cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Yattering82
Level: Power Up

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
Highlighted
Community Support Team
Community Support Team

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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.
92 REPLIES 92
brandonklittle
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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

Highlighted
Community Support Team
Community Support Team

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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.
Yattering82
Level: Power Up

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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

rsaarik
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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. 

kristof805
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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:

 

VendorEmail1.pngFailed 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!

 

kristof805
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

@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:

VendorEmail2.pngCheck 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!

 

 

rsaarik
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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!

kortvez
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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.

sbusby
Level: Power Up

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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.

kristof805
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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!

Victoria
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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

kristof805
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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. 

 

 

Victoria
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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
kristof805
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

@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.

Victoria
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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

 

 

 

 

kristof805
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

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

Victoria
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

Ok sorry, let's try again!

 

flow failure.png

 

 

flow failure2.png

 

Thanks, Vicki

kristof805
Level: Powered On

Re: FLOW TO SEND EMAIL WHEN DATE APPROACHES

@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
firstImage

Microsoft Flow Online Conference

Join us for a FULL day of FREE Microsoft Flow Sessions from some of the best minds in the industry!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

thirdImage

New Flow Community Board!

Check out the new Microsoft Flow Community Blog Topic Suggestion board!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 42 members 4,082 guests
Please welcome our newest community members: