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

Date formatting error when trying to create planner task from a message in teams

Hi, so I'm trying to use this flow template which will create a task in planner when I post a new message to a Teams channel.

 

However, the flow fails with the following error - The request is invalid: Cannot convert the literal '' to the expected type 'Edm.DateTimeOffset'.

 

I tried formatDateTime but it shows the same error. I tried utcnow() as well. Here is what the original flow looks like:

yashm_0-1621441317866.png

This is the error with the above flow:

 

yashm_1-1621441446464.png

 

Here are the expressions I tried:

yashm_2-1621441555215.pngyashm_3-1621441599305.png

All show the same error as above. So I tried converting it to dd/MM/yyyy using this expression:

 

formatDateTime(triggerBody()?['createdDateTime'],'dd/MM/yyyy')

 

Still it failed with the same error:

yashm_4-1621441799675.png

 

Please tell me what should I do. I saw other posts where some or the other formula from the above worked for people. For some reason, they are not working for me! 

 

13 REPLIES 13
Pstork1
Dual Super User III
Dual Super User III

Its expecting a DateTime in ISO 8601 format.  If the time you are inputting is already in UTC then you can format it using the following

formatDateTime(inputtime)

.  If you don't specify a format string it will use UTC 8601.

if the time you want to use is in a Local time zone then convert it using the following, where 'Eastern Standard Time' is replaced by the name of the local timezone.

convertToUtc(inputtime,'Eastern Standard Time')

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi, I tried this and still got an error - 

yashm_0-1621444765637.png

"The template language function 'convertToUtc' expects its second parameter to be a time zone matching the time zone indicated by the timestamp. The provided value '(UTC-05:00) Eastern Time (US & Canada)' is not valid or does not match the timestamp '2021-05-19T16:03:55.5490000Z"

 

This is the default format in which the date is in: 2021-05-19T16:03:55.5490000Z 

Pstork1
Dual Super User III
Dual Super User III

The error is because the timestamp you are using is already in UTC, not in the local timezone.  So you can't convert it to UTC from Eastern time.  You should be able to use that value directly or use the first version that just formats it to ISO 8601.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
yashm
Helper II
Helper II

That's what! It's giving an error in the default UTC format as well as the first version of ISO 8601.

Both the cases: 2021-05-19T16:03:55.5490000Z & 2021-05-19 or 19-05-2021 are showing the 'Cannot convert the literal '' to the expected type 'Edm.DateTimeOffset' error

Pstork1
Dual Super User III
Dual Super User III

Is this a flow based on a Template?  The screenshot you posted is slightly different than the current action to Create a Task.  If it is based on a template you might want to deleting the action and re-adding the current supported action. I tried to recreate your error using a literal timestring and UTCNow() and both worked without error.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
yashm
Helper II
Helper II

Yes it is based on a template. The default flow wasn't working that's why I modified it. Can you share screenshots of your flow? 

Pstork1
Dual Super User III
Dual Super User III

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Yes, it's working when I replicate the above. But not with the teams dynamic content. 

Replicated flow:

yashm_0-1621451293394.png

Default template flow:

yashm_1-1621451348545.png

Output:

yashm_2-1621451381152.png

As you can see, the Start Date Time is literally the same in both cases

Pstork1
Dual Super User III
Dual Super User III

Ok, let me take a look at it with a trigger like you are using.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Pstork1
Dual Super User III
Dual Super User III

I changed the trigger and it still works for me.  I'm not sure what the issue is for you.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
yashm
Helper II
Helper II

Not sure why I'm getting a bad request on my end. Anyway, thanks for your help!

Pstork1
Dual Super User III
Dual Super User III

Make sure all the actions in the flow are using the most recent version.  One of the problems with templates is that they often break after underlying actions are updated.  Those updates are happening constantly.  I'm working off a hand built flow, not a template.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (961)