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

formatDateTime using Dynamic Content

Hello,

 

I am attempting to create an event in Outlook 'When a todo list item is created'. I continue to run into the issue that Outlook requires a time zone in its "start time" field. Todo does not, at least by default, provide a timezone which causes the outlook connector to automatically put in "T00:00:00". This causes the flow to fail, as it is not an accepted time zone. 

 

I am currently trying to use the 'formatDateTime' function to reformat it including my timezone (CST 06:00:00) but it returns the same error each time after failing;

 

"InvalidTemplate. Unable to process template language expressions in action 'Create_event_(V4)' inputs at line '0' and column '0': '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.'."

 

The expression I am currently trying to use is;

 

formatDateTime(outputs('Get_a_to-do_(V3)')?['body/dueDateTime/dateTime'], 'yyyy/mm/ddThh:mm:ss')
 
My goal is to take the date/time that is given to me from Microsoft ToDo, format it to satisfy Outlook, and have my flow run through to create the event. The timezone is not important to me whatsoever, so if there is a way to create an outlook event without that option that would also work.
 
Thanks in advance
1 ACCEPTED SOLUTION

Accepted Solutions
jatcube
Solution Supplier
Solution Supplier

@emiller6 so I actually tried it in our work tenant to see what happens, and to my biggest surprise I wasn't even presented with a Due Date Option in the create event action. So I gave the good ol' convert time zone function a try and lo and behold it worked perfectly. It may work for you too?

convertTimeZone(outputs('Get_a_to-do_(V3)')?['body/dueDateTime/dateTime'],'Central America Standard Time','Central America Standard Time','s')

 

View solution in original post

14 REPLIES 14
Expiscornovus
Super User
Super User

Hi @emiller6,

 

It looks like in this case you have triggered the flow with a To Do task which does not have a due date at all. That is why you are getting a null value error.

 

So, I would build in some logic to handle these tasks without due dates. What do you want to do if a task does not have a due date?

 

Btw, if you are using a To Do trigger action I would expect the expression to be something like below. I have also modified the datetime format slightly. As far as I am aware the Create event (v4) expects the yyyy-MM-ddTHH:mm:ss format.

 

 

formatDateTime(triggerOutputs()?['body/dueDateTime/dateTime'], 'yyyy-MM-ddTHH:mm:ss')

 

todo_createevent.PNG

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


emiller6
Regular Visitor

I have a different flow that is using data from a Microsoft Form submission to create the to do task. The to do task does in fact have a due date, and is required to via the flow I have been using to create it. The original flow works, and creates the todo task successfully with the right information. The second flow, the one I am describing, is supposed to take the information from the todo list and create an Outlook event.

 

In short;

 

Microsoft form submission --> ToDo Task

ToDo Task --> Outlook Event

Expiscornovus
Super User
Super User

Hi @emiller6,

 

In that case can you share a screenshot of the setup of your second flow?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


emiller6
Regular Visitor

Within the form I have created, it requires an answer in the "start time" field.

2.PNG

Expiscornovus
Super User
Super User

Hi @emiller6,

 

I mean, can you share a screenshot of the ToDo Task --> Outlook Event flow setup (which you referred to as second flow 😉)?



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


jatcube
Solution Supplier
Solution Supplier

@emiller6 your error would indicate that outputs('Get_a_to-do_(V3)')?['body/dueDateTime/dateTime'] does not have any value, not that it doesn't have the timezone info.

 

However, I think there's a bit of confusion here. the outlook create event expects the time zones as literal expressions, such as "(UTC-06:00) Central Time (US & Canada)" which you can set manually in TimeZone. The Start and end time specifically does not need a timezone.

 

What it does, it expects the time in the '2017-08-29T04:00:00' format where anything after the T is just the 24 hour time for the event. As I said above, the timezone is selected a step further.

 

So if we take the above example and put 2017-08-29T04:00:00 as start time with UTC -6 as timezone, you'll create an event at 4am UTC-6. or if you change the timezone to GMT but leave everything as is, you'll create the event at 4am GMT.

 

If you found this response useful, give it a thumbs up and don’t forget to mark your post answered to help others find the solution easier.

This does give some insight, however previously when I tried to run these flows without the time zone data it consistently errors out in the same place, but says it cannot create the event because the date/time format is incorrect. This was when, in the start/end time fields, I had a dynamic content which inserted the “due date” from the todo task.

I posted it previously, but here it is again.

B698AEB6-4A2B-41C2-87F1-041B62564CFD.png

jatcube
Solution Supplier
Solution Supplier

@emiller6 the due date is returned in the required format already, no need to format it.

Due Date	dateTime		date-time	
YYYY-MM-DDThh:mm:ss

  https://docs.microsoft.com/en-us/connectors/todo/ 

emiller6
Regular Visitor

I thought so to, yet when I don't do any formatting and just use the "due date" dynamic content this is what I get returned;

 

String was not recognized as a valid DateTime.
clientRequestId: a5b61bd7-a496-462f-9475-b95d6114667b

 

 "status"400,
  "message""String was not recognized as a valid DateTime.\r\nclientRequestId: a5b61bd7-a496-462f-9475-b95d6114667b",
  "error": {
    "message""String was not recognized as a valid DateTime."
  },
  "source""office365-cus.azconn-cus-001.p.azurewebsites.net"
jatcube
Solution Supplier
Solution Supplier

@emiller6 can you just do a compose or just get the output of the @{triggerOutputs()?['body/dueDateTime/dateTime']} and see what it actually says?

 

I just did a test and for me it returns it in the 2022-09-06T23:00:00 format which outlook create event connector happily accepts, so not sure where your flow goes belly up...

emiller6
Regular Visitor

This is what I get when I attempt to just use the dynamic content with no reformatting or special functions.

22.PNG

jatcube
Solution Supplier
Solution Supplier

@emiller6 so I actually tried it in our work tenant to see what happens, and to my biggest surprise I wasn't even presented with a Due Date Option in the create event action. So I gave the good ol' convert time zone function a try and lo and behold it worked perfectly. It may work for you too?

convertTimeZone(outputs('Get_a_to-do_(V3)')?['body/dueDateTime/dateTime'],'Central America Standard Time','Central America Standard Time','s')

 

That worked! Thank you so much, I'm very new to flow and certainly wouldn't have figured that out myself.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,842)