Showing results for 
Search instead for 
Did you mean: 
New Member


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.

106 REPLIES 106



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.

Not applicable



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



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:



Not applicable



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



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?

Not applicable



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



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!

Not applicable



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.





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.

Not applicable



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.



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.

Not applicable





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



Try switching your formula to "@lessOrEquals" and try to do a test run to see what happens.

Not applicable



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.



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.

Not applicable



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.




Wow, thank you so much for your help!! Really hoping to get the hang of it. Seems like a very powerful tool.



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.

Not applicable



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?



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?

Not applicable



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

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Top Solution Authors
Users online (1,472)