cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Continued Contributor
Continued Contributor

Date/Time Format for SharePoint Calendar

I am having some difficulty with Date/Time formats in my flow.

 

The Flow is triggered by PowerApps (Canvas App) and is creating events in a SharePoint calendar (classic calendar, not modern).   

 

There are 2 parts to this flow.  The first part creates the SharePoint item (Create Item action) and then the second part updates that item to set the 'AllDayEvent' flag (Send an HTTP Request to SharePoint).

 

In the original version of the flow, the create item was using the datepicker selected date with no additional formatting from the PowerApps collection.    The calendar item was created successfully, but had a random time in each item.   The update step (Send and HTTP Request to SharePoint) errors out with the error:

 

"error": {
"code": 502,
"source": "flow-apim-msmanaged-na-westus2-01.azure-apim.net",
"clientRequestId": "5ec2029c-f09f-4aee-84aa-1a63018c237d",
"message": "BadGateway",
"innerError": {
"message": "Invalid date/time value.\n\nA date/time field contains invalid data. Please check the value and try again.\r\nclientRequestId: 5ec2029c-f09f-4aee-84aa-1a63018c237d\r\nserviceRequestId: a6592d9f-6035-a000-9fa2-c271745bb65f",
"status": 502,
"errors": [
"-2130575332",
"Microsoft.SharePoint.SPException"
]
}
}
 
So I tried formatting the date coming out of PowerApps differently and that causes the create item step to fail.
 
Not sure what I need to do for it to see the date/time as valid.
3 REPLIES 3
Highlighted
Super User II
Super User II

Re: Date/Time Format for SharePoint Calendar

Hi @JR-BejeweledOne 

 

This is for sure a difference in the date format produced in your PowerApp and your SharePoint calendar.

 

Please check:

1. SharePoint's settings to validate what date/time format it's expecting (for example yyyy-mm-dd or yyyy-dd-mm).

2. Check if the date is formated like that.

3. When the error occurs please check the date that is failing. The error is silent sometimes because 2020-02-01 can be the the first of February or the second of January but SharePoint will accept it since it's a valid date.

 

Hope this helps and makes sense.

 

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

Cheers
Manuel

Highlighted
Continued Contributor
Continued Contributor

Re: Date/Time Format for SharePoint Calendar

I don't have any way to know which date is failing though.   It could be the EventDate (Start Date) or the End Date.   The error doesn't specify.  

 

So the flow has these steps:

1. Create Item

2. Send HTTP Request (update item)

 

In the create item step it's using the date from the PowerApps date picker, default format.   I haven't done any formatting of the date/time in the DatePicker and this is a canvas app, not a SharePoint list app.

 

The event is being successfully created with the date from the datepicker in the PowerApp being used for the Start and End date fields in the sharepoint calendar.   This tells me that the format is correct otherwise it wouldn't be able to use it to create the event.

 

I am not sure where this leaves me troubleshooting wise though.

Highlighted
Continued Contributor
Continued Contributor

Re: Date/Time Format for SharePoint Calendar

After much trial and error and searching for answers I have resolved the problem. 

 

In the original attempt to format the date I was using a formatDateTime expression that was referring to triggerBody.   This threatened to break my flow, which is being triggered by PowerApps.  

 

Once I realized that triggerBody was causing the initial error, I tried multiple formatDateTime options and date conversions to no avail.   I stumbled upon a post that pointed me to the true solution which was reformatting the date in PowerApps before passing it to Flow.

 

Here is the scenario and solution.

 

PowerApp triggered flow to create an 'All Day' event in a SharePoint calendar.

 

After creating the event using the Create Item SharePoint action, you need to use a Send HTTP Request to SharePoint action to set 'fAllDayEvent' to true.

 

This will cause errors if you are not passing the correctly formatted date to update the EventDate and EndDates to drop the time.

 

I set 2 dates.  One that is used to create the initial event in the calendar, this is just the standard date picker value and the second date is formatted to an ISO text format.  This is passed directly into the Send HTTP Request action.

 

This is the formatted date to use in the Send HTTP request action.

{EventDate: Text(dpDate.SelectedDate,"[$-en-US]yyyy-mm-ddThh:mm:ss")}

 

First Action - Create Item uses the standard date picker valueFirst Action - Create Item uses the standard date picker value

 

 

2nd Action, Send HTTP request, uses the specially formatted date2nd Action, Send HTTP request, uses the specially formatted date

 

 

 

Helpful resources

Announcements
secondImage

August 2020 CYST Winners!

Check out the winners of the recent 'Can You Solve These?' community challenge!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (4,578)