Issue
Recently, we had a requirement to sync the calendar between the shared mailbox Outlook and SharePoint Calendar list. We have created two flows.
- Outlook to SharePoint Sync: this one syncs the changes in Outlook calendar to SharePoint
- SharePoint to Outlook Sync: this one syncs the changes in the SharePoint calendar to Outlook.
When a user enters any event in the SharePoint calendar, the second flow executes and tries to create a new event in the shared mailbox outlook. We have used the Create event (v4) action. This action causes the below error in some cases.
Error: Your request can't be completed. At least one property failed validation.
Analysis
- The first thing we needed to check was in which scenario the error was occurring. So, when we analyzed the issue, it was occurring only for day events.
- The second thing we needed to check was what was missing in the parameters. But we didn’t get anything missing in that.
- The third thing we checked was whether there was any logic issue when we passed the parameters. In this, we found the solution.
Resolution
So, as we go through different steps in the analysis, we find that when we pass parameters, there is something wrong. So, we passed the details as they are without making any changes in the data to the outlook event, and it was completed successfully.
We have used the formula below to convert the date.
formatDateTime(
triggerOutputs()?['body/EndDate'],
'yyyy-MM-ddTHH:mm'
)
The issue here was when we had a day event, the formula was setting the start date as “yyyy-MM-ddT12.00” and the end date was supplied as “yyyy-MM-ddT11.59”. The format was using AM/PM time, but that was not passed in the create event. So, the end date was 1 minute less than the start date, which created the issue.
We updated the format with below the 24-hour format.
formatDateTime(triggerOutputs()?['body/EndDate'], 'yyyy-MM-ddTHH:mm:ssZ')
This resolved the issue of creating an event. I have added a reference link that explains the formatDateTime function in detail. You can review that link for more format options.