cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JKnox
Frequent Visitor

Error Sending Notification based on date comparison

 
Attempting to send an email based on an SP Date field called Expiration Date. 7 Days after the expiration date a notification should be sent. I tried using a condition, compose, filter array and  double checked my formats and all fail. 
 
 Formula:
 
 
@equals(formatDateTime(item()?['Expiration_x0020_Date'], 'yyyy-MM-dd'), formatDateTime(addDays(utcNow(), 7), 'yyyy-MM-dd'))
 
Error:
 
''InvalidTemplate. The execution of template action 'Filter_array' failed: The evaluation of 'query' action 'where' expression '@equals(formatDateTime(item()?['Expiration_x0020_Date'], 'dd-MM-yyyy'), formatDateTime(addDays(utcNow(), 7), 'dd-MM-yyyy'))' failed: '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.'.''
 
6 REPLIES 6
v-yuazh-msft
Community Support
Community Support

Hi @ JKnox,

 

Could you please share a screenshot of the configuration of your flow?

The error message told that the provided "Expiration Date" is null, please check if the "Expiration Date" in the item is null, you could have a try to add a condition to check if the "Expiration Date" is null.

 

Could you please share more details about the trigger in your flow?

If you would like to check the "Expiration Date" of all items in the sharepoint list, you could create a flow as screenshot below:

Capture.PNG

The expression in the condition as below:

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

The expression in the condition 2 as below:

@equals(formatDateTime(items('Apply_to_each')?['Expiration_x0020_Date'], 'dd-MM-yyyy'), formatDateTime(addDays(utcNow(), 7), 'dd-MM-yyyy'))

 

The flow would run successfully as below:

Capture.PNG

 

 

 

 

Regards,
Alice Zhang

Hi @v-yuazh-msft - Unfortunately, your suggestion did not work. After I adjusted the flow to your specifications I received notifications for all items on my list with any Expiration Date. The trigger on my workflow is Recurrence.

Configuration-  Recurrence, Get Items (Filtered by Status and LOB) the filter that array based on the expiration date comparison. After it would send a notification.

 

Hi @ JKnox,

 

Could you please share a screenshot of the configuration of your flow?

Could you please share more details about the sharepoint list?

 

Further,could you please share more details about what you want to achieve and what is the problem when you create the flow so we could try to help you.

 

 

Regards,
Alice Zhang

@v-yuazh-msft

 

Screenshshots - I have attempted in several browser to add screenshoots to the conversation and I am unable to. (Yes I have adjusted my security settings). Is there another way I can send you screenshots.

 

SharePoint List- Basic Custom list with 1 look up field.

 

Purpose of Flow - To send a notification on a specific date based on another day. For example the Expiration date is set to 3/31/2018, I would like to send a notification 7 days prior.

Hi @ JKnox,

 

 

I have made a test on my side, and the solution that I have provided in worked on my side, please take a try to my solution again, and you could modify the trigger to recurrence.

Please make sure you have add the condition2 that I have provided, and fill in the correct expression in condition2. 

 

Regards,
Alice Zhang

I tried it again. It sends emails for all the items in the list that do not meet the condition. I have over 1,000 items on my list. Only 2 meet the condition of Exp date +7.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (82,686)