cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
antoniebrown1
Level: Powered On

Adding days using expression in a Apply for each condition

Hi I am new to Flow and I am creating a flow for D365 to run once a day and check Accounts that have a contract end date approaching in 2 weeks from now, I then need to send them an email.

 

The area i am struggling with is within my 'Apply to Each', I  am adding a condition with an expression but it is saying invalid expression.

 

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

 

I want the condition to get the contractenddate that are 14 days from today, so I can email them a reminder but im stuck at the expression.

 

9 REPLIES 9
Super User
Super User

Re: Adding days using expression in a Apply for each condition

Hi @antoniebrown1 

 

Is field 'new_contractenddate' is always having a value? Make sure it is not null.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



antoniebrown1
Level: Powered On

Re: Adding days using expression in a Apply for each condition

Hi the field is an optional field on account. Does it need to be a required field ?
Super User
Super User

Re: Adding days using expression in a Apply for each condition

Hi
So if it's optional then there is no value and you have a format date time expression which trying to convert to a certain format hence invalid expression you getting. Add an if condition to check whether the value is null before the if condition.


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



antoniebrown1
Level: Powered On

Re: Adding days using expression in a Apply for each condition

Hi abm could you help me with the if condition before I try the format?
Community Support Team
Community Support Team

Re: Adding days using expression in a Apply for each condition

Hi @antoniebrown1 

 

If the new_contractenddate field is choice type field, you need to choose the new_contractenddate value dynamic content of the "Get items" action, the expression should as below:

items('Apply_to_each')?['new_contractenddate']?['Value']

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

antoniebrown1
Level: Powered On

Re: Adding days using expression in a Apply for each condition

Hi @abm 

I have attached the screen shot, I am struggling to understand on how to implement items('Apply_to_each')?['new_contractenddate']?['Value'] with my expression '@equals(formatDateTime(item()?['new_contractenddate'], 'MM/dd/yyyy'), formatDateTime(addDays(utcNow(), 14), 'MM/dd/yyyy'))'

 

The goal is to get the records from List records that have the new_contractenddate in 14 days from now and send them a reminder email.

Capture1.PNG

Super User
Super User

Re: Adding days using expression in a Apply for each condition

Hi @antoniebrown1 

 

I could help you with a screenshare? 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Highlighted
antoniebrown1
Level: Powered On

Re: Adding days using expression in a Apply for each condition

@abmthanks for the advise on using 'Compose' this is now in progress and will update when all is complete

Community Support Team
Community Support Team

Re: Adding days using expression in a Apply for each condition

Hi @antoniebrown1 ,

 

Have your problem been solved?  If yes, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (2,126)