Blog
Data - How to save and retrieve Google calendar entries
March 14. 2021
Power Apps provides a connector to retrieve and to add Google calendar entries. The syntax for this connector isn't very obvious so in this post, we'll walk through an example of how to display contacts in a gallery control, and how to add contacts to a Google account.
The ability to access Google calendar entries can be very useful,
particularly for organisations that use GSuite, or cases where app
builders want to provide an easy way to retrieve, access, or to sync records from an Android device.
In this post, we'll walk through the syntax that enables us to manage Google calendar entries.
In this post, we'll walk through the syntax that enables us to manage Google calendar entries.
Introduction to connector
To use this connector in a canvas app, the first step is to add a connection through the data panel.The Google Calendar connector offers a range of features, including actions to:
- Show a list of available calendars
- List the calendar entries for a specific calendar
- Add, delete, and retrieve calendar entries
- Update a calendar entry
Retrieving a list of available calendars
Calendar entries are stored in calendars, and we can retrieve a list of available calendars by calling the ListCalendars action. GoogleCalendar.ListCalendars().items
The screenshot beneath shows the output when we set the items property of a data table control to this formula.
A key value that this action returns is the id for each calendar. This defines the unique identifier for the calendar, and we require this to show the calendar entries for a specific calendar.
Retrieving/Searching calendar entries
To retrieve the calendar entries for a specific calendar, we call the ListEvents action. This action requires a calendar ID. The formula beneath highlights the simple use of this action. Here, we provide the ID of the selected calendar from the data table of available calendars.GoogleCalendar.ListEvents(dtGoogleCalendars.Selected.id).items
GoogleCalendar.ListEvents(
dtGoogleCalendars.Selected.id,
{timeMin:Text(DateAdd(Now(), -2, Months), DateTimeFormat.UTC),
timeMax:Text(Now(), DateTimeFormat.UTC),
q:"project catchup"
}
).items
This formula returns all calendar entries from the past two months that contain the phrase "project catchup" in any of the fields.
We must specify the from and to datetime values (timeMin and timeMax) in UTC format. UTC format looks like this - yyyy-MM-ddTHH:mm:ss.fffZ (2016-07-20T08:00:00.000Z).
The q parameter specifies the search text query, and we can omit this if we want to return all records.
We must specify the from and to datetime values (timeMin and timeMax) in UTC format. UTC format looks like this - yyyy-MM-ddTHH:mm:ss.fffZ (2016-07-20T08:00:00.000Z).
The q parameter specifies the search text query, and we can omit this if we want to return all records.
The screenshot beneath shows the output when we set the items property of a data table control to the ListEvents action.
This highlights the existance of an id value that uniquely identifies each event. We can pass this to the UpdateEvent, DeleteEvent, and GetEvent actions.
Other calendar attributes that we can access include description, summary, start, end, created (ie, the create date/time), attendees, htmlLink, location, organiser, status, and updated (ie, the updated date/time).
Other calendar attributes that we can access include description, summary, start, end, created (ie, the create date/time), attendees, htmlLink, location, organiser, status, and updated (ie, the updated date/time).
Creating a Calander Entry
The formula to create a calendar entry looks like this:GoogleCalendar.CreateEvent(
dtGoogleCalendars.Selected.id,
"2021-03-11 23:00",
"2021-03-11 23:15",
{
description: "description value",
location: "location value",
attendees: "tim@myEmailDomain.com",
status: "status value",
isAllDay: false
}
)
The first 3 mandatory arguments are the target calendar ID, the start time for the event, and the end time of the event.
The 4th argument specifies a record with additional event details. The fields in this record include:
Updating a calander entry
The formula to update a calendar entry looks like this:
The first 2 mandatory arguments are the target calendar ID, and the target event ID. Just like the CreateEvent action, the final argument specifies a record that contains the calendar details to update.
Deleting a calander entry
The formula to delete a calendar entry looks like this:
The 2 mandatory arguments are the target calendar ID, and the target event ID.
The 4th argument specifies a record with additional event details. The fields in this record include:
- description - the description of the event.
- location - free-form text that describes the geographic location of the event.
- attendees - a comma-separated list of attendee emails.
- status - the 3 acceptable values are "confirmed", "tentative", or "cancelled".
- IsAddDay - a true/false value to indidcate if this is an all-day event.
Updating a calander entry
The formula to update a calendar entry looks like this:GoogleCalendar.UpdateEvent(
dtGoogleCalendars.Selected.id,
dtCalendarEvents.Selected.id,
{
start:"2021-03-11 23:00",
end:"2021-03-11 23:10",
description: "project catchup updated",
location: "location value",
attendees: "it_tim@yahoo.com",
status: "confirmed",
isAllDay: false
}
)
Deleting a calander entry
The formula to delete a calendar entry looks like this:GoogleCalendar.DeleteEvent(
dtGoogleCalendars.Selected.id,
dtCalendarEvents.Selected.id
)
Conclusion
Power Apps provides a Google calander connector that we can use to show a list of available calendars, and to add, delete, update, and retrieve events from calendars. This post highlighted the formulas that enable us to carry out these tasks.- Categories:
- data
- date and time
Related posts
- Data - How to find the common rows from 3 or more collections
- Data - How to show the distinct rows from 2 data sources or collections
- Data - How to implement circular rotational date sorting
- Bug - What to do when the data section of the Power Apps Maker portal doesn't work
- Data - Combine columns from separate tables into a single table
- Formula - Transposing/converting rows to columns- an almost impossible task?
- Data - How to rename field names in a record
- Data - How to hide duplicate rows in a gallery / show distinct multiple columns in a gallery
- Data - Retrieving news/forum/blog articles with RSS
- Data - How to sort by partial numbers in a text field
- Data - How to return the last record from a table
- Data - How to create bulk test/dummy records with random values
- Data - 3 things you should know before using the MySQL or PostgreSQL connectors
- Data - A walkthrough of how to migrate the data source of an app from Excel to Sharepoint
- Data - How to enforce unique values (or prevent duplicate values) in one or more columns
- Data - How much mobile data does Power Apps consume? What ways can we minimise this?
- Data - How to save and retrieve Google contacts
- SQL - Caution! This is how users can hack shared SQL connections
- SharePoint – 2 Mistakes to avoid when importing Excel data
- SQL - Don't let this DateTime bug catch you out!
- Settings - What's the purpose of the "Explicit Column Selection" Setting?
- SQL Server for Beginners Part 3 - Installing On-Premises Gateway
- SQL Server for Beginners Part 2 - Installing Management Studio
- SQL Server for Beginners Part 1 - Installing SQL Server
- Searching data–What you need to know about case sensitivity
- Images - How to create images that can change depending on data
- Excel - Reasons NOT to use Excel as a data source
- SharePoint - What you need to know about Filtering Data
- Formulas - Generating Row Numbers