Get schedule of another Office365 user in PowerApps

Let’s look at a simple business requirement. Manager needs to know free/busy times for any selected user within the organization/team. Native PowerApps methods/functions do not support viewing another user’s calendar. Therefore, we need to create a custom connector for this.

Creating custom PowerApps connector

  1. Create an application in Azure AD for authentication
  2. Grant below API permissions to graph
Permission typePermissions (from least to most privileged)
Delegated (work or school account)Calendars.Read, Calendars.ReadWrite
Delegated (personal Microsoft account)Not supported.
ApplicationCalendars.Read, Calendars.ReadWrite

3. Go to > Data > Custom Connectors. Create a new connector

4. Configure Security tab with Azure app credentials

5. Save the custom connector to generate the redirect URL. Copy and paste the URL as Azure app redirect URL.

3. Go to “Definition” tab and let’s start creating the methods. Check the graph API documentation for the relevant method. In this case, it is calendar:getSchedule. View API documentation here.

Use Graph Explorer to format your request and response accordingly.

4. Add a new action as a POST method. Simply copy and paste the method from Graph Explorer.

5. Navigate to default response section and click “Import from sample”. You can copy the sample response from Graph Explorer and paste it here.

6. Once done, import and the output variables will appear in the body.

7. Click “Update connector” and move to test tab.

8. Now, we need to create a connection to use this custom connector. Click “New Connection”. This will prompt a new connection creation screen. Click “Create”. You will need to enter your Microsoft credentials and login.

This will create a new connection.

9. Now, navigate to the custom connector > Test tab and test the new connector

We are getting a valid response. Connector seems to be working fine. Now we need to use this custom connector and the method in PowerApps.

Using the custom connector in PowerApps

This custom connector returns a set of meeting records for a specific user. We need to store this information in a table like structure to use this data. Let’s use a collection for this.

  1. Create a blank canvas app
  2. Add a button
  3. Add custom connector to the application

4. For button OnSelect attribute, use below code:

        "<Current User GUID>",
            schedules: ["<Specific user email address>"],
            startTime: {
                dateTime: "2020-06-15",
                timeZone: "Pacific Standard Time"
            endTime: {
                dateTime: "2020-06-30",
                timeZone: "Pacific Standard Time"
            availabilityViewInterval: 60

5. Save and run the application.

6. Go to view > Collections. New collection should appear.

7. Expand Schedule Items column. Meetings should be visible.

So far, we were able to create a custom connector for Microsoft Graph API and get schedules for any user and then load it to a collection called “ThisCalendar”. All we have to do now is to change the request body and insert variables to dynamically populate the collection.

In the next post let’s see how we can extend the Organization Browser Standard app to view schedule(Free/Busy) for any user.

Happy Learning!

Categories: PowerApps

Tags: ,

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: