SharePoint Events

Create New Events in SharePoint: MS Power Automate

Premise

In this post we’ll discuss how to create a new event in the OOTB Events list in modern SharePoint Online Communication sites.

Solution

There’s no direct action card in MS Power Automate to create an event. However, we can use the standard ITEMS API to create a new list item in the Events list. While doing so, we just need to ensure that we’re updating all the required metadata values correctly.

Since, we’ll be using the SharePoint Rest API, the same approach can also be used in other custom solutions as well, to create Events. For ex., SPFx, Add-Ins, etc.

MS Power Automate

SharePoint Create Events

Code Snippet [Body]

{
    '__metadata': {
        'type': 'SP.Data.EventsListItem'
    },
    'fAllDayEvent': 'false',
    'EventDate': '@{variables(' startDate ')}', //addDays(utcNow(),2)
    'EndDate': '@{variables(' endDate ')}', //addHours(addDays(utcNow(), 2),2)
    'Title': 'Test Event from Flow: PK',
    'Category': 'Meeting',
    'Location': 'Pune, India',
    'Geolocation': {
        '__metadata': {
            'type': 'SP.FieldGeolocationValue'
        },
        'Latitude': 18.5204,
        'Longitude': 73.8567
    },
    'Description': '<b>Agenda</b><br/><br/>Test event created by <b>Piyush</b> from MS Flow' //supports rich text format
}

The solution can be divided in to the following 2 sections:

  • Flow Header
  • Flow Body

Flow Header

EntityValueUsage
Site AddressThe URL of the site.
MethodPOSTFixed
Uri/_api/web/lists/getByTitle(‘Events’)/items Fixed. Please ensure that the name of our list is ‘Events’ only. Otherwise, use your custom list name.
Content-Typeapplication/json;odata=verboseIndicates we’re sending the data in JSON format
Acceptapplication/json;odata=verboseIndicates we’re requesting to receive the data in JSON format. [Optional]

Flow Body

PropertyValueUsage
‘__metadata’‘type’: ‘SP.Data.EventsListItem’This value is usually fixed for all Events list. But it’s always better to double check its value. You can find more info regarding the same here.
fAllDayEventfalseIs all day event
EventDate2020-05-04T14:31:04.6240863ZStart date of your event. It accepts the value in ISO 8601 format. Here, I’ve just used the formula, addDays(utcNow(),2)
EndDate2020-05-04T16:31:04.9053567ZEnd date of your event. I’ve added couple of hours to the EventDate. Indicating that our event duration is of 2 hours. addHours(addDays(utcNow(), 2),2)
TitleTitle of your event
CategoryMeeting category. [Optional]
LocationPune, India[Optional]
Geolocation{
‘__metadata’: {‘type’: ‘SP.FieldGeolocationValue’},
‘Latitude’: 18.5204,
‘Longitude’: 73.8567
}
Maps co-ordinates of the meeting location. [Optional]
DescriptionMeeting agenda. It supports rich text formatting.

On running the above flow, a new event will be created as per the info provided.

SharePoint Events Web Part

Key Takeaways

  • Events list is just like any other SharePoint list.
  • We’re using the standard SharePoint REST API to create a new entry into this list.
  • All the time values provided [EventDate & EndDate] are supposed to be in ISO 8601 format only.
  • The date values should be entered equivalent to their UTC date/time only.
  • I’m using the default, Geolocation field. However, in order to create a map view, please ensure that all the prerequisites are satisfied first.

3 thoughts on “Create New Events in SharePoint: MS Power Automate

  1. Hi. thanks for sharing this. I am trying to create a flow to add an entry in the sharepoint Events list when a new item is added into a customized list. I got following error when follow your example to create a flow:
    {“odata.error”:{“code”:”-1, Microsoft.SharePoint.Client.InvalidClientQueryException”,”message”:{“lang”:”en-US”,”value”:”The expression \”web/lists/getByTitle(\u2018Events\u2019)/items\” is not valid.”}}}
    clientRequestId: a696aa6d-3172-4267-a3d3-41310e9db592
    serviceRequestId: c0138e9f-a0d9-2000-7810-b7a7efb520c1

    How can I fixe this?

    thanks
    Jim

    Like

    • Copying from this page uses incorrect quotes. Replace with this: \u2018Events\u2019 with ‘Events’ (Events surrounded by single quotes)

      Like

  2. How can I create an event that can be automatically managed with Sharepoint, Power Automate, or Power Apps? I teach several different classes and would like to set up a flow that allows users to register, without overfilling the slots in my course. Could you help me?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.