Update 22/7/2019: Loryan has published his article, where he explains in more detail what he wants to achieve, and which other things he tried. Check it out here: https://www.loryanstrant.com/2019/07/22/giving-yourself-a-clear-view-to-focus-on-your-day/

A couple of days ago, I saw the following question from fellow Office 365 MVP Loryan Strant:

His goal was to have a combined view of his (Office 365) calendar’s entries and his To-Do items for the current day, so that he can display them prominently on his Surface device, while he’s using his monitor for his work.

By the time I saw this tweet, the conversation was already relatively active, with some discussions about using the Graph API and/or PowerApps. Sounded like a perfect opportunity to me, to quickly create another PowerApp to learn a thing or two, and help someone else.

As I often do, I start by showing the end result first before explaining the implementation, so that it’s much clearer what we were trying to achieve:

The screenshot above shows the app in its current form. It’s not perfect, and there are many things that can be improved, but the goal was to get a first working version ready for Loryan to test and (hopefully) use.

I started by creating a new Canvas app for a tablet, and added Office 365 Outlook and Outlook Tasks as data sources. While Loryan wanted to show the To-Do items, it turned out that the To-Do Connector and API currently do not allow us to retrieve the items that we want to show, thus we use the “regular” Tasks Connector.

The following code is used in the OnStart property of the app as well as on the Refresh icon (OnSelect) on the top right:


ClearCollect(
     Calendars,
     Office365.CalendarGetTables().value
 );

 ClearCollect(
     MyCalendarEvents,
     Office365.GetEventsCalendarViewV2(
         First( Filter( Calendars, DisplayName = "Calendar" ) ).Name,
         Text( Today(), UTC ),
         Text( DateAdd( Today(), 1, Days), UTC )
     ).value
 );

 ClearCollect(
     MyTasks,
     OutlookTasks.GetAllTasks()
 );

The code first retrieves all calendars from Outlook, as there may be more than one. I then retrieve all events from the calendar named ‘Calendar’ (yes, hardcoded here as it works for both me and Loryan, and I decided to not add any additional functionality to work with it dynamically) that fall in the current day (start time is today midnight, end time is tomorrow midnight). Last but not least, we retrieve all Outlook tasks.

On my screen, I added a Gallery control to show the Calendar entries:

As Loryan wanted to only show Calendar events that have not passed yet, and hide any entries that lie in the past, I updated the Items property to the following, so that only current and future events are shown:

Filter( 
   MyCalendarEvents,
   End >= Now()
)

For the Tasks, I also added a Gallery control:

As we actually retrieve all Tasks, and not just those for today, we need to apply a filter to only show those that are due today. And because we don’t want to show completed Tasks, we add another filter to exclude those that have the Status set as ‘Completed’.

Filter(
     MyTasks,
     DateValue(Text(DueDateTime.DateTime)) = DateValue(Text(Today())),
     Status <> "Completed"
)

One important thing to note here is that within To-Do, you have a section called “My Day”. However, it is not possible to figure out via the current Tasks Connector if an entry is within “My Day”. Thus, Loryan agreed to the following workaround:
Items in “My Day” also get marked as “Due today”, and are thus affected by the filter we use above.

And that’s it! There are certainly many things that can be done to improve the app (auto-refresh every hour? show more useful information about events and tasks? …), but as it is in a working state (and as I didn’t receive further improvement requests from Loryan so far), I did not try to do anything else with it. If you want to review the app, make some changes/improvements, and maybe even use it yourself, it is available on my Github account.

9 thoughts on “Creating a consolidated calendar and To-Do tasks view in PowerApps”

  1. Love how simply you present the request and the solution. Very easy to follow scenario and how to steps for seeing today’s personal Office 365 activity.

    1. Thanks Tom! Was surprised how easily this could be achieved, definitely a good showcase for the Power Platform and how quickly useful solutions can be developed.

  2. This is wonderful. A few suggestions:

    Show multiple calendars, including those that you are subscribed too
    An action that opens the calendar or todo item in outlook
    a new button for both, again launching outlook and the new calendar entry / task form
    does it manage all day events?

    Let’s also hope that To-Do API matures so you can get more data directly from there, as lists and sub tasks don’t come across that well in Outlook tasks

    1. Hi John,

      yes, it handles all-day events.
      As for opening calendar entries, this can be done with the following code, for example for OnSelect on the Title label in the CalendarEventsGallery1:
      Set(_selectedCalendarEvent, ThisItem); Launch(Concatenate("https://outlook.office.com/calendar/item/",Substitute(EncodeUrl(_selectedCalendarEvent.Id),"-","%2F")))

      To create a new calendar entry, add a new label/button/icon and add the following code to the OnSelect property:
      https://outlook.office.com/owa/?path=/calendar/action/compose

      Will check on different calendars as well. Possible, but want to see how to make it user-friendly

  3. Hint: In Germany you must use another Displayname=”Kalender” in the Filter, so perhaps for other Languages

  4. Hello! I’m looking to convert the backend data from my Outlook calendar to draw from a SharePoint List – do you know if this is possible?

    1. Hi Rob, can you explain what you mean? Not sure if I understand you correctly.
      But in case you’re wondering if you could get “calendar” data to be shown in the app from a SharePoint list instead of an Outlook calendar, yes, that’s possible.

Leave a Reply to Karl G. Schneider Cancel reply

Your email address will not be published. Required fields are marked *

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