cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JR-BejeweledOne
Super User
Super User

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.


If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
1 ACCEPTED SOLUTION

Accepted Solutions

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

 

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

View solution in original post

22 REPLIES 22
manuelstgomes
Community Champion
Community Champion

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

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.



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.

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

 

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
Hedi69
Helper I
Helper I

Dear friend,

 

Thank you so much for this procedure.

One thing please: When you say: "I set 2 dates", could you please explain how to set these date ?

I have only 3 columns in my list: Title, Start Date, End Date

The event is properly created in the Sharepoint Calendar: "Absence Calendar"

But I am not able to update the AlldayEvent to YES

Thank you so much for your help.

I am setting two dates in the App itself.   One is just the standard date picker date and that is what is saved to the SharePoint Start Date and End date columns.   Both dates are saved to the collection that the flow is processing.

 

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

 

The date value is used when initially creating the SharePoint item.   As you can see it's just the value from the date picker.

 

In the Send HTTP request action in the flow we are using the Event Date.  Notice how it's formatted.   This is what is considered an ISO format.  In my case it's formatted for US English.   You can modify that part to fit your needs.  The event date is not used in the Create SharePoint item action, only in the Send HTTPS request action.

 

I hope this answers your question.  



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
Hedi69
Helper I
Helper I

Now I have an error with the URI:

Hedi69_0-1643394818176.png

 

Hedi69
Helper I
Helper I

The name of my calendar is Absece Calendar

Hedi69
Helper I
Helper I

Absence Calendar sorry

What is the error you are getting and is this a classic SharePoint calendar list?



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
Hedi69
Helper I
Helper I

Yes classic view for the calendar

Hedi69
Helper I
Helper I

My List :

Hedi69_0-1643395633203.png

 

Hedi69
Helper I
Helper I

Hedi69_1-1643395682458.pngHedi69_2-1643395711064.png

 

Hedi69
Helper I
Helper I

But now I just want tp modify the item with AllDayEvent Attibute

JR-BejeweledOne
Super User
Super User

Can you screen shot the error you are getting?



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
Hedi69
Helper I
Helper I

Détails de l'erreur

{"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"The expression \"web/lists/getbytitle(\"Absence Calendar\")/items(755)\" is not valid."}}}
clientRequestId: 75c23a35-e441-4ae5-9212-1b0cdc0534fc
serviceRequestId: eb421ba0-30b4-1000-6d2d-8706e5a12715

Hedi69
Helper I
Helper I

Hedi69_0-1643396387731.pngHedi69_1-1643396419925.png

 

I think it's complaining about the date formatting

 

try changing it:  Text(dpDateInput.SelectedDate,"[$-fr-FR]yyyy-mm-ddThh:mm:ss")



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
JR-BejeweledOne
Super User
Super User

Actually did you type the URI directly into the field or did you use the expression builder and type it there?



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
Hedi69
Helper I
Helper I

I type manually the URI to the field

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.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (2,733)