cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PresidentWillem
Regular Visitor

'Create a task' does not accept null or empty string in date fields

I am using 'Create a task' flowstep to generate tasks in a Microsoft Planner. But sometimes I do not want to enter a date value for the start or end date. It depends on a variable being entered or not. I use the following expression:

 

if(empty(variables('StartTime')),null,variables('StartTime'))

 

It returns a 400 error, bad request, stating that it was impossible to convert null to a datetime, which is correct. But I do not want to enter anything at all. I've also tried the following:

 

if(empty(variables('StartTime')),'',variables('StartTime'))

 

Same result, only this time it couldnt convert the empty string. Funny thing is, when I do not enter anything at all, it seems to be fine.

 

How do I go about making these datefields variably entered or left empty?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @PresidentWillem,

 

Ok, so the min time is 1/1/1984 11:00:00 AM +00:00, you could use this timestamp instead of 1900/01/01.

 

Best Regards,
Community Support Team _ Lin Tu
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

6 REPLIES 6
Hardesh15
Super User II
Super User II

@PresidentWillem 

May i know how you add Date & time filed in a variable. Please share screen.

Thanks

Hardesh

v-litu-msft
Community Support
Community Support

Hi @PresidentWillem,

 

Yes, if there are some expressions in the StartDate field of Create a task action, there should contain a valid date, or it will report an error.

As a workaround, you could create a condition action to determine the startdate variable whether empty, if it is empty, go to the branch that create task action which startdate filed leave empty, for example:

Annotation 2020-07-15 141903.jpg

 

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

Thanks for your answer, although this does not seem like a good enough solution.

Because next up is EndDate, so then you would have to make 2 additional conditions within your given solution. I mean, that would probably work, but that can't be the right way to approach a simple problem like this, right?

Hi @PresidentWillem,

 

Yes, it is a workaround that not make users confused through it is a little complex.

There has a another way, if the StartTime is empty, set the time to a invalid time:

if(empty(variables('StartTime')),'1900-01-01',variables('StartTime'))

 

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

I have checked your solution but it results in the following error:

 

Schema validation has failed. Validation for field 'StartDate', on entity 'Task' has failed: The value must be between 1/1/1984 11:00:00 AM +00:00 and 12/31/2149 11:00:00 AM +00:00 inclusive.
Validation for field 'DueDate', on entity 'Task' has failed: The value must be between 1/1/1984 11:00:00 AM +00:00 and 12/31/2149 11:00:00 AM +00:00 inclusive.

Hi @PresidentWillem,

 

Ok, so the min time is 1/1/1984 11:00:00 AM +00:00, you could use this timestamp instead of 1900/01/01.

 

Best Regards,
Community Support Team _ Lin Tu
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

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

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (3,465)