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

112 REPLIES 112
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

Power Platform Connections - Episode 7 | March 30, 2023

Episode Seven of Power Platform Connections sees David Warner and Hugo Bernier talk to Dian Taylor, alongside the latest news, product reviews, and community blogs.     Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show.  

Announcing | Super Users - 2023 Season 1

Super Users – 2023 Season 1    We are excited to kick off the Power Users Super User Program for 2023 - Season 1.  The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts.      Super User Season 1 | Contributions July 1, 2022 – December 31, 2022  Super User Season 2 | Contributions January 1, 2023 – June 30, 2023    Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile.  Power Apps  Power Automate  Power Virtual Agents  Power Pages  Pstork1*  Pstork1*  Pstork1*  OliverRodrigues  BCBuizer  Expiscornovus*  Expiscornovus*  ragavanrajan  AhmedSalih  grantjenkins  renatoromao    Mira_Ghaly*  Mira_Ghaly*      Sundeep_Malik*  Sundeep_Malik*      SudeepGhatakNZ*  SudeepGhatakNZ*      StretchFredrik*  StretchFredrik*      365-Assist*  365-Assist*      cha_cha  ekarim2020      timl  Hardesh15      iAm_ManCat  annajhaveri      SebS  Rhiassuring      LaurensM  abm      TheRobRush  Ankesh_49      WiZey  lbendlin      Nogueira1306  Kaif_Siddique      victorcp  RobElliott      dpoggemann  srduval      SBax  CFernandes      Roverandom  schwibach      Akser  CraigStewart      PowerRanger  MichaelAnnis      subsguts  David_MA      EricRegnier  edgonzales      zmansuri  GeorgiosG      ChrisPiasecki  ryule      AmDev  fchopo      phipps0218  tom_riha      theapurva  takolota     Akash17  momlo     BCLS776  Shuvam-rpa     rampprakash  ScottShearer     Rusk  ChristianAbata     cchannon  Koen5     a33ik  Heartholme     AaronKnox  okeks      Matren   David_MA     Alex_10        Jeff_Thorpe        poweractivate        Ramole        DianaBirkelbach        DavidZoon        AJ_Z        PriyankaGeethik        BrianS        StalinPonnusamy        HamidBee        CNT        Anonymous_Hippo        Anchov        KeithAtherton        alaabitar        Tolu_Victor        KRider        sperry1625        IPC_ahaas      zuurg    rubin_boer   cwebb365   Dorrinda   G1124   Gabibalaban   Manan-Malhotra   jcfDaniel   WarrenBelz   Waegemma   drrickryp   GuidoPreite    If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances.  Once they are received the list will be updated. 

Register now for the Business Applications Launch Event | Tuesday, April 4, 2023

Join us for an in-depth look into the latest updates across Microsoft Dynamics 365 and Microsoft Power Platform that are helping businesses overcome their biggest challenges today.   Find out about new features, capabilities, and best practices for connecting data to deliver exceptional customer experiences, collaborating, and creating using AI-powered capabilities, driving productivity with automation—and building towards future growth with today’s leading technology.   Microsoft leaders and experts will guide you through the full 2023 release wave 1 and how these advancements will help you: Expand visibility, reduce time, and enhance creativity in your departments and teams with unified, AI-powered capabilities.Empower your employees to focus on revenue-generating tasks while automating repetitive tasks.Connect people, data, and processes across your organization with modern collaboration tools.Innovate without limits using the latest in low-code development, including new GPT-powered capabilities.    Click Here to Register Today!    

Check out the new Power Platform Communities Front Door Experience!

We are excited to share the ‘Power Platform Communities Front Door’ experience with you!   Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well.   Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities.     Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform.      Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.

Microsoft Power Platform Conference | Registration Open | Oct. 3-5 2023

We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida.   Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more.   Register today: https://www.powerplatformconf.com/   

Users online (4,712)