I have a PowerApp that I'm using for Event / Class Registrations. When someone registers for an event or class, it creates an item in our SharePoint list. I have a PowerAutomate Flow created that runs when a new item is created in the SP List and sends an email to the person who registered for the class, and then subsequently creates an event for the class in their outlook calendar.
However, I'm running into errors when trying to pass the Start Time & End Time from the SharePoint list. I got the following error message:
Unable to process template language expressions in action 'Create_event_(V4)' inputs at line '1' and column '32820': '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.'.
And sometimes, if I don't use anything to convert the date and time, I will get this message while trying to save the flow:
Flow save failed with code 'OpenApiOperationParameterValidationFailed' and message 'Input parameter 'item' validation failed in workflow operation 'Create_event_(V4)': The parameter with value '"@items('Apply_to_each')?['EventStart']"' in path 'item/start' with type/format 'String/date-time' is not convertible to type/format 'String/date-no-tz'.'.
The flow won't simply allow me to add the item from 'Get Items', "EventStart, and EventEnd." It's not formatting correctly. In addition to this, when the flow does run (if I use a generic date and time for start and end), it creates 3 duplicate events in the user's calendar when it should only be creating it one time.
Here is the flow I have so far:
I've tried using the following expressions to get the date / time to format:
convertToUtc(triggerOutputs()?['body/start'], 'Eastern Standard Time')
convertToUtc(triggerOutputs()?['body/start'], 'GMT Standard Time')
but none of these seem to work, and I still get an error, and if I don't get an error, it still creates the same even 3 times.
One of the expressions above worked, but it didn't create the event on the date and time it is set for in the list, it created the event for the same day I registered for the event. *** We are using Central Standard Time ***
This is what the date and time look like in the SharePoint List:
I hope this makes sense, but I don't know where else to go.
From your error, I can see that you are using formatdatetime but in your flow screenshot, I dont see any such function. Can you please confirm where in the flow you are using this function? It seems it is getting null value.
Here is the example where I'm using this:
However, this creates the calendar event the same day I register, instead of the actual session date/time. It also creates 3 duplicate events.
I tried using this to format the EventStart and EventEnd time: formatDateTime(item()?['EventStart'],'dd/MM/yyyy') and got the following error:
FYI - The dates in Sharepoint are both Date / Time fields. So there is also a time included, which I can't seem to get to work either ;(
Can you please format using following format?
Thank you, but unfortunately, I still get the following error:
Do I need to put the same function in for the EventEnd (End Time) too, or just the Start Time?
Yes. You will have to use function for both start and end.
In your recent screen shot, I dont see a loop. What happened to loop? Are you getting these dates from trigger action? If yes, can you select those from dynamic content?