cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jrogles
Frequent Visitor

Recreating Recurring Sharepoint Calendar Events

I'm trying to make a daily flow that checks a sharepoint site's event calendar, and any event marked as birthday (or recurring/etc) -- I'd like to create a new event with all of the same information except the start and end date's year is incremented by one. I'm trying to sidestep the modern ui's ignoring of recurring events, while also avoiding having to make an event: every year for every employee.

 

*** Updated the main post instead of replying: ***

 

Current Problem:

502 Bad Gateway on the HTTP Request to Sharepoint trying to Update the Create Item with the fAllDayEvent param set to true. Any help is greatly appreciated on the HTTP Request.

 

 

Current Flow:

Screen Shot 2019-03-14 at 10.36.33 PM.pngScreen Shot 2019-03-14 at 10.36.53 PM.pngScreen Shot 2019-03-14 at 10.37.30 PM.pngScreen Shot 2019-03-14 at 10.37.47 PM.png

 

Current Failed Test with a 502 Bad Gateway -- Event Time Date Error

Screen Shot 2019-03-14 at 10.33.32 PM.pngScreen Shot 2019-03-14 at 10.33.54 PM.pngScreen Shot 2019-03-14 at 10.34.07 PM.pngScreen Shot 2019-03-14 at 10.34.17 PM.pngScreen Shot 2019-03-14 at 10.34.26 PM.pngScreen Shot 2019-03-14 at 10.35.07 PM.pngScreen Shot 2019-03-14 at 10.35.23 PM.pngScreen Shot 2019-03-14 at 10.35.35 PM.pngScreen Shot 2019-03-14 at 10.35.48 PM.png

 

More on the error:

Screen Shot 2019-03-14 at 11.00.32 PM.pngThe Events are still made:

Screen Shot 2019-03-15 at 12.30.06 PM.png

1 ACCEPTED SOLUTION

Accepted Solutions
Jrogles
Frequent Visitor

Solution!! The fAllDayEvent flag needs to be passed with new start/end times with the hh:mm:ss removed.

Thanks to @v-yamao-msft for pointing me to this article on my other thread.

 

Here are the two final flows I used (I realize they can be combined) to recreate recurring, all-day events on Sharepoint Online Event Calendars:

 

Screen Shot 2019-03-31 at 10.40.15 PM.png

 

Recurring Events:

Screen Shot 2019-03-31 at 10.50.39 PM.png

 

addDays function:

addDays(utcNow('yyyy-MM-dd'),-1,'yyyy-MM-dd')

 

utcNowfunction:

utcNow('yyyy-MM-dd')
 
Category Value contains "Birthdays"
 

addDays function:

addDays(utcNow('yyyy-MM-dd'),1,'yyyy-MM-dd')

Screen Shot 2019-03-31 at 10.51.27 PM.png

empty function:

empty(body('CheckIfItExists')?['value'])

 

Screen Shot 2019-03-31 at 10.51.39 PM.png

 

 

Make any new Birthday - an all day eventScreen Shot 2019-03-31 at 10.45.41 PM.png

formatDateTime #1 & #2:

formatDateTime(triggerBody()?['EventDate'],'M/d/yyyy')

 

URI:

_api/web/lists/GetByTitle('Events')/items(@{triggerBody()?['ID']})

 

Headers:

{
"Content-Type": "application/json;odata=verbose",
"IF-MATCH": "*",
"X-HTTP-Method": "MERGE",
"Accept": "application/json;odata=verbose"
}

 

Body:

{
"__metadata": {
"type" : "SP.Data.EventsListItem"},
"fAllDayEvent" : "True",
"EventDate" :"@{formatDateTime(triggerBody()?['EventDate'],'M/d/yyyy')}",
"EndDate" :"@{formatDateTime(triggerBody()?['EventDate'],'M/d/yyyy')}"
}

View solution in original post

10 REPLIES 10
Jrogles
Frequent Visitor

cleaning up thread

Jrogles
Frequent Visitor

more cleanup

Jrogles
Frequent Visitor

thread cleanup, made a lot of progress

Jrogles
Frequent Visitor

Here is the full text of the 502 Error.

 

{
"error": {
"code": 502,
"source": "flow-apim-msmanaged-na-eastus2-01.azure-apim.net",
"clientRequestId": "cbc5a112-576f-4682-b8f4-234058867f03",
"message": "BadGateway",
"innerError": {
"status": 502,
"message": "Invalid date/time value.\n\nA date/time field contains invalid data. Please check the value and try again.\r\nclientRequestId: cbc5a112-576f-4682-b8f4-234058867f03\r\nserviceRequestId: 50aeca9e-d0f2-8000-7958-ecc8417b6892",
"source": "____/sites/H20/_api/web/lists/GetByTitle('Events')/items(454)",
"errors": [
"-2130575332",
"Microsoft.SharePoint.SPException"
]
}
}
}

 

I'm really unsure how using the original start time, the add to time action, and a even a formatDateTime can still yield me bad date/time data for entry on the object.

 

The new event is created fine with those date/times -- so why is updating the all day event flag, throwing an invalid date/time error? Is this completely unsupported functionality for sharepoint calendars now?

 

Also trying to use the Expression True value for fAllDayEvent param throws a 400 invalid JSON error. 

Jrogles
Frequent Visitor

So I think this is boiling down to the fact that the fAllDayEvent isn't being set to a Boolean value for some reason.

 

Here the new item is set to:

<d:fAllDayEvent m:null="true" />

 

Instead of what the existing item's fAllDayEvent is set as:

<d:fAllDayEvent m:type="Edm.Boolean">true</d:fAllDayEvent>

 

Not having any luck with these--

"fAllDayEvent":true

"fAllDayEvent" : "True"

"fAllDayEvent" : "true"

"fAllDAyEvent" : "{expression 'true'}

Screen Shot 2019-03-25 at 11.22.04 AM.png

 

How should I format the JSON body of the HTTP request to get the proper syntax on the update-item set?

Jrogles
Frequent Visitor

Solution!! The fAllDayEvent flag needs to be passed with new start/end times with the hh:mm:ss removed.

Thanks to @v-yamao-msft for pointing me to this article on my other thread.

 

Here are the two final flows I used (I realize they can be combined) to recreate recurring, all-day events on Sharepoint Online Event Calendars:

 

Screen Shot 2019-03-31 at 10.40.15 PM.png

 

Recurring Events:

Screen Shot 2019-03-31 at 10.50.39 PM.png

 

addDays function:

addDays(utcNow('yyyy-MM-dd'),-1,'yyyy-MM-dd')

 

utcNowfunction:

utcNow('yyyy-MM-dd')
 
Category Value contains "Birthdays"
 

addDays function:

addDays(utcNow('yyyy-MM-dd'),1,'yyyy-MM-dd')

Screen Shot 2019-03-31 at 10.51.27 PM.png

empty function:

empty(body('CheckIfItExists')?['value'])

 

Screen Shot 2019-03-31 at 10.51.39 PM.png

 

 

Make any new Birthday - an all day eventScreen Shot 2019-03-31 at 10.45.41 PM.png

formatDateTime #1 & #2:

formatDateTime(triggerBody()?['EventDate'],'M/d/yyyy')

 

URI:

_api/web/lists/GetByTitle('Events')/items(@{triggerBody()?['ID']})

 

Headers:

{
"Content-Type": "application/json;odata=verbose",
"IF-MATCH": "*",
"X-HTTP-Method": "MERGE",
"Accept": "application/json;odata=verbose"
}

 

Body:

{
"__metadata": {
"type" : "SP.Data.EventsListItem"},
"fAllDayEvent" : "True",
"EventDate" :"@{formatDateTime(triggerBody()?['EventDate'],'M/d/yyyy')}",
"EndDate" :"@{formatDateTime(triggerBody()?['EventDate'],'M/d/yyyy')}"
}

Trying to update SharePoint Online Event list using MS flow HTTP to Sharepoint Action but running into the following error "A type named 'SP.Data.EventsListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type."

 

Any ideas what I am doing wrong or missing?  Below is my Request and the Response I get. 

 

:Request

Header:
{
"Content-Type": "application/json;odata=verbose",
"IF-MATCH": "*",
"X-HTTP-Method": "MERGE",
"Accept": "application/json;odata=verbose"
}
Body:
{
"__metadata": {
"type" : "SP.Data.EventsListItem"},
"fAllDayEvent" : "True",
"EventDate" : "@{formatDateTime(body('Create_item')['EventDate'],'M/d/yyyy')}",
"EndDate" : "@{formatDateTime(body('Create_item')['EventDate'],'M/d/yyyy')}"
}

 

 

:Response

{
"status": 400,
"message": "A type named 'SP.Data.EventsListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type.\r\nclientRequestId: eaae8b9c-8fbc-4513-a14d-de9e581111dd\r\nserviceRequestId: 10acef9e-c0a7-8000-8706-7a79ffb54afa",
"source": "[tenanturl][site]/_api/web/lists/GetByTitle('Events')/items(429)",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}

WHCWeb

 

I ran into the same error: "A type named 'SP.Data.EventsListItem' could not be resolved by the model"

 

I resolved it by updating the reference to "Events" in the "SP.Data.EventsListItems" to match the name of my calendar/list.  The example json code provided assumes the calendar/list is called "Events".  If it is not, then you need to update the json code.  If your calendar/list is call "Example" then you need to change the code to refer to "SP.Data.ExampleListItem".

 

In my case, my list was called "Birthdays" which meant I had to update the body json code to (bold emphasis added):

 

{
"__metadata": {
"type" : "SP.Data.BirthdaysListItem"},
"fAllDayEvent" : "True",
"EventDate" :"@{formatDateTime(triggerBody()?['EventDate'],'M/d/yyyy')}",
"EndDate" :"@{formatDateTime(triggerBody()?['EventDate'],'M/d/yyyy')}"
}

 

Hope this helps.

 

Regards

 

Michael

kwmetz88
Regular Visitor

 can you list out some of the custom variables for what you did here? I am trying to recreate but can't see everything

Spreij
New Member

@Jrogles 

 

Thanks for working this out. Was hoping to use it but I seem to get a error message saying: Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The action(s) 'CheckIfItExists' referenced by 'inputs' in action 'Condition_2' are not defined in the template.'.'.

 

I followed only your solution steps, reading old informatie I found that CheckifitExists is often overcome by things like this solution: https://powerusers.microsoft.com/t5/Building-Flows/How-to-check-if-an-item-exists-on-a-SharePoint-li...  . However I do not see that in one way or a other set in your solution. Did I miss something? Where did you define CheckIfitExists or how should I go about it? 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (2,826)