cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
surfer1978
Helper I
Helper I

Format all planner task dates in Flow

Hi

I am trying to format dates for planner tasks when I email them.

 

I followed this solution

https://powerusers.microsoft.com/t5/Building-Flows/Planner-Flow-Date-Value-Format-Error/m-p/249542#M...

 

I have found that if there is no date in the planner task due date, the flow will fail to run, is there any way to skip trying to format the date if the duedate is null?

 

I also need to do this to the start date and the completed date, is there an elegant way to basically get all the dates from the task details and if there are any dates present format them so I can use them in an email template?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
RezaDorrani
Dual Super User II
Dual Super User II

Hi @surfer1978 

 

In that second compose 2 action

use the following expression

 

if(equals(outputs('Compose'),null),'',formatDateTime(outputs('Compose'),'yyyy-MM-dd'))
This will only format the date if it exists else output blank
 
You can do the same for the other date fields
 

Regards,

Reza Dorrani

 

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

5 REPLIES 5
RezaDorrani
Dual Super User II
Dual Super User II

Hi @surfer1978 

 

In that second compose 2 action

use the following expression

 

if(equals(outputs('Compose'),null),'',formatDateTime(outputs('Compose'),'yyyy-MM-dd'))
This will only format the date if it exists else output blank
 
You can do the same for the other date fields
 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

@surfer1978 

Reza and I responded at the same time....his is better. go with that 😉   

 

Hi there!

So...dates are all going to be stored the same way.  I'm guessing you'll want to change the presentation before they are presented in an email, right?

There are a few ways to go about this depending on how comfortable you are with expressions.  It's not my strongest point, but I've found this kind of thing to be handy...

 

Here's the one from the thread you mentioned:     formatDateTime(outputs('Compose'),'yyyy-MM-dd')


So, we want to see if the field is empty before trying to format it, right?   Try this in the expression box:   if(empty(outputs('Compose'),'',formatDateTime(outputs('Compose'),'yyyy-MM-dd')))

 

Totally winging it so it may yell at you, but basically asking if there's a value in the output, and if not keep it blank, and if so, format the value.

 

Keep us posted.

-Ed-

 

 

If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

v-alzhan-msft
Community Support
Community Support

Hi @surfer1978 ,

 

Have your problem been solved?

Please take a try with @edgonzales's  and @RezaDorrani 's  solution, and you could also consider adding a Condition under the Compose 2 action to check if the task due date is null, and you could add different Set TaskDetails Variable for the task due date in the If yes and If no branch of the Condition.

 

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.

Thank you @RezaDorrani  that worked perfectly 

Hi

 

I have the exact same issue as this. I have edited the template flow task which emails outstanding tasks to a group at a given time.

 

I've used the formatDatetime expression to get the dates the way I want them(the email shares title of task, start date and due date).

 

When there is no start date/due date the flow fails. I've tried to edit the expression and add:

 

if(equals(outputs('Compose'),null),'',formatDateTime(outputs('Compose'),'dd-MM-yyyy'))

 

but it just tells me that the expression is invalid. Any ideas?

 

Thanks

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,743)