cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

How to check if a field (date) is blank AND it is within a specific number of days then send email

I have a business process where I need to take the following steps....just not sure how to code it in FLOW:

 

Step 1: Determine if [Funded End Date] is NOT blank

Step 2: IF [Funded End Date] field IS blank do nothing  

Step 3: IF NOT blank determine if [Funded End Date] is 1 day greater than today

Step 4: If YES send an e-mail to specific people | If NO do nothing

 

Run this everyday at a specific time

 

This seems to be a pretty standard problem and I've used this code @equals(formatDateTime(item()?['Funded_x0020_End_x0020_Date'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), 10), 'MM/dd/yyyy'))   before to send notices.

 

The issue I'm running into is that the not all the Funded End Date fields have data, and won't.  So I the first part of the code throws an error becuase it's trying to evaluate a blank field

 

FLOW Blank Field Issue.png

 

Thanks in advance for any help! 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Advocate III
Advocate III

Re: How to check if a field (date) is blank AND it is within a specific number of days then send email

I came across a similar issue today and couldn't find a solution in the community, but then found a workaround that may be of interest for some users for determining if a date field is blank:

 

Value(Today()) - Value('Due Date') = Value(Today()) returns True if Due Date is blank.

 

View solution in original post

30 REPLIES 30
Highlighted
Advocate II
Advocate II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

Hey DarenD,

 

I have ran into issues trying to evaluate too much in one expression condition - even if everything makes logical sense. Now I split up more steps, both Flow and my coworkers seem to like it better.

 

I would

  1. Initialize a boolean Variable outside the loop
  2. Then inside your Apply to each, Set the Variable something like
    1. Set boolean Variable = not(empty(item()?['Funded_x0020_End_x0020_Date']))
  3. Add another conditional branch where if the Fund date is TRUE (not empty) continue on to your other within 10 days condition, else do nothing

Capture.PNG

Highlighted
Helper II
Helper II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

Sooo...what action/condition am I looking for to create the variable?  I can't seem to find it in the FLOW actions.

Highlighted
Helper II
Helper II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

Oh my gosh....as soon as I posted this I found it. Sorry. 

Highlighted
Helper II
Helper II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

Charles_John,

     I think I've followed the instructions provided but can't find the "true" boolean value. What am I missing?

 

VariableIssue.png

Highlighted
Helper IV
Helper IV

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

I basically do the same exact thing in my Flow. I first check if the date field on this SharePoint list is NOT blank with the following code inside a condition:

 

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

(the above is under an Apply to Each, just like you have it). So, if it is empty, nothing happens, if it is NOT empty, it goes to another condition where it checks if the date from the list is 30 days away from today or not. If it is not, nothing happens, if it IS 30 days away from today, I get an e-mail reminder sent to me.

 

@equals(formatDateTime(item()?['Nextauditdue'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), 30), 'MM/dd/yyyy'))
Highlighted
Helper II
Helper II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

I must be missing something, because I've got a Definition Error (see arrow) and I can't find "true" in condition value.

 

VariableIssue2.png

Highlighted
Helper IV
Helper IV

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

Hey @DarenD

 

I actually use it without the variable initilization and true/false checking. I just add a condition under the Apply to each step and go to edit in advanced mode and paste the code in there. Also make sure the title of your column is correct but it looks like you've already done this from your screenshot.

Highlighted
Helper II
Helper II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

Ah, let me try that and see if I can kick start this bad boy!

Highlighted
Helper II
Helper II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

krisof805,

 The FLOW ran but I didn't get a notice and I've got one date set to 8/21/2018 (trying to test for just 1 day to see if I can get it to work).  Please see the two pix below:

 

Something Didn't workSomething Didn't workNot sure if code is incorrectNot sure if code is incorrect

Highlighted
Helper IV
Helper IV

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

@DarenD

 

I think your first screenshot indicates that the Flow didn't get to that step because the item was empty in that particular instance?

 

The second screenshot has your date out 10 days, and not 1, if I am not mistaken. I think you would need a date for 8/30/2018 or 8/31/2018 for the Flow to evaluate to true and send you an e-mail.

 

 

Highlighted
Advocate II
Advocate II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

@DarenD

 

The not(empty(item()?['Funded_x0020_End_x0020_Date'])) needs to be an expression, or use the @ operator as I think you did in your next attempt

 

Capture6.PNG

 

 

Highlighted
Advocate II
Advocate II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

@DarenD

 

Using this approach you are referring to the wrong object.

@not(empty(triggerBody()?['RD_x0020_Funded_x0020_Expiration_x0020_Date'])) 

 

You want to referrence each element in the loop. Use below instead:

@not(empty(items('Apply_to_each')?['RD_x0020_Funded_x0020_Expiration_x0020_Date'])) 

 

Using the Expression and Dynamic Content tab to select your elements and build your formulas will help avoid the incorrect objects.

 

 

For your second box highlighting the comparision value in the condition, again, you can type in true in the Expression fx box. I think you can also directly just type in true to the comparision text box.

Highlighted
Helper II
Helper II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

So I'm now a bit confused.  This is due to me being so new at FLOW but this is clearly an important issue for me to get fixed as I'll be using it in several other FLOWs.  

 

Charles_John,

    I added the code where you recommended, I believe, and it did run but no notice went out. I feel like I'm super close and just missing somethign small. You and Kristof805 are being super helpful and patient and I really, really appreciate it!!! 

 

So I have file in my library with an RD Funded Expiration Date of 8/22/2018, this is my test file.   

 

In my "Apply to Each" Action I have the first condition of:

 @not(empty(items('Apply_to_each')?['RD_x0020_Funded_x0020_Expiration_x0020_Date'])) 

 

If YES then second condition of:

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

 

If RD Funded Expiration Date is 1 day ahead (YES) then send an e-mail.  What am I missing?

 

CodeIssue3.png

Highlighted
Helper IV
Helper IV

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

@DarenD

 

Your code looks good to me! Have you checked any of your runs for what is inside the Get files (properties only) -> Outputs -> Body results? That shows all the stuff your Flow is getting back from your files, you should see your dates there.

 

Have you tried a test run or two with this latest setup? Do you get a failure? Runs okay but no e-mails?

Highlighted
Advocate II
Advocate II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

Hi DarenD,

Glad to help! Couple suggestions:

 

1. Add an action on the No/False branch of your condition to help in debuging. Then you'll be able to see if the condition isn't being evaluated as expected. This is why I also recomend Initializing/Setting variables. It's easier to see what's happening when debugging.

  • Note that your comparing sharepoint dates - which i'm assuming aren't entered in UTC time - against UTC now. I don't think this is the error in this case, but may cause timing differences in the future depending on what region you're in.

2. I would suggest building expressions using the Dynamic content selections and Expression formula until you're more familiar with objects. This will ensure you have correct references.

Capture.PNG

 

  • In your second condition is this giving you your expected value?
    •  @equals(formatDateTime(item()?['RD_x0020_Funded_x0020_Expiration_x0020_Date'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), 1), 'MM/dd/yyyy'))
  • I think it might, but you could change to 
    •  @equals(formatDateTime(items('Apply_to_each')?['RD_x0020_Funded_x0020_Expiration_x0020_Date'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), 1), 'MM/dd/yyyy'))

 

Highlighted
Helper IV
Helper IV

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

I just tried to make sure everything is working and it is with the following code and item with the date of 9/20/2018 (that's 30 days away from today according to Flow):

 

Expiration.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If the a date does end up being empty, the 30 days away step will throw and error saying that it did not get to that step but overall the Flow calls the run a success and so do I.

Highlighted
Helper II
Helper II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

Charles_John,

    I added an e-mail in the first condition and recieved 200+ e-mails on items that had blank funding date fields. So that part works. However, the next condition isn't working properly. Even when I added your code updates.  See below:

email1.pngCodeIssue4.png

Highlighted
Helper IV
Helper IV

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

@DarenD I think that means that the Flow did not make it to that step (which is fine .. if a date is blank you can't compare it to a date from 30 days from now) but @Charles_John sounds like they know more than me. 

 

So the blank date part is working. Did you set any dates to 8/22/2018 so you would get a single e-mail if the Yes side of the condition evaluates?

Highlighted
Helper II
Helper II

Re: How to check if a field (date) is blank AND it is within a specific number of days then send ema

Yes, I have 1 file with that date for testing purposes.  I think FLOW hates me! LOL! 

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Top Kudoed Authors
Users online (7,339)