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

Populating Calendar with SQL table data

I am trying to create a simple app that displays a calendar.  I have inserted the calendar frame onto my page and it is automatically pulling a couple different calendars, including my outlook calendar.   Can someone point me in the right direction to create a new calendar based off of data from an SQL table.  For example I have an SQL database with a table like this:

 

Start Time   

End Time
Duration
Description

Name of Tech

 

 

I would like to be able to populate a calendar with this information and then filter on the "Name of Tech" field.  Thanks.

 

 

4 REPLIES 4
Highlighted
Super User II
Super User II

Re: Populating Calendar with SQL table data

What 'calendar frame'? are you referring to?

How is your Outlook Calendar connected to it? Just passing the Calendar data, or a reference to it?

Since we are visualizing a calendar - need to understand what is being used to display it, to understand how to transform your data into that format.

Highlighted
Frequent Visitor

Re: Populating Calendar with SQL table data

Insert \ New Screen \ Calendar   is the "frame"  I was referring to.   I am just trying to figure out a way to either use this control against data from a table (as in my example if possible) or if there was a way to create a calendar from my table data and point to that.   I'm not certain how I got this control/page connected to my outlook calendar it was just there.   Thanks for your help.

 

Highlighted
Super User II
Super User II

Re: Populating Calendar with SQL table data

Gotcha!

That is a template screen which MSFT provides. By default, it is now adding a Data Source (Office365Outlook) to your app, and then performing relatively complicated functions to organize and present the data to do.

For example, the OnSelect of the Calendar Drop Down is this function

/*retrieves calendar events for all days in current month view and selected calendar 
_minDate and _maxDate act as markers to prevent duplicate data collection*/         
If(IsBlank(_userDomain),         
	UpdateContext({_showLoading: true});         
	Set(_userDomain, Right(User().Email, Len(User().Email) - Find("@", User().Email)));         
	Set(_dateSelected, Today());         
	Set(_firstDayOfMonth, DateAdd(Today(), 1 - Day(Today()), Days));         
	Set(_firstDayInView, DateAdd(_firstDayOfMonth, -(Weekday(_firstDayOfMonth) - 2 + 1), Days));         
	Set(_lastDayOfMonth, DateAdd(DateAdd(_firstDayOfMonth, 1, Months), -1, Days))         
);         
Set(_calendarVisible, false);         
UpdateContext({_showLoading: true});         
Set(_myCalendar, dropdownCalendarSelection1.Selected);         
Set(_minDate, DateAdd(_firstDayOfMonth, -(Weekday(_firstDayOfMonth) - 2 + 1), Days));         
Set(_maxDate, DateAdd(DateAdd(_firstDayOfMonth, -(Weekday(_firstDayOfMonth) - 2 + 1), Days), 40, Days));         
ClearCollect(MyCalendarEvents, Office365Outlook.GetEventsCalendarViewV2(_myCalendar.Name, Text(_minDate, UTC), Text(_maxDate, UTC)).value);         
UpdateContext({_showLoading: false});         
Set(_calendarVisible, true)

You can definitely tweak this function to meet your needs.

HOWEVER, you will need to also review all of the controls that are added to the screen and tweak them to meet your needs. This is not a simple undertaking; but gives you a great place to start.

This guide will help you: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/screen-templates/calendar-screen-overvi...

 

Highlighted
Frequent Visitor

Re: Populating Calendar with SQL table data

Thanks for your help.  I have spent several hours now trying to get this to work only to discover that the reason I am not seeing any data is that Powerapps is not able to delegate the filter by date to the SQL server.  Soooo basically I can not filter by date on a table that is over 500 records (in my case I'm way over that) unless I add a computed integer date field into my SQL table.  Seems like maybe this is a bug that has been around since 2016 without a fix.  Lucky me I stumble onto this in my first evening with Powerapps.  I am beyond disappointed.   

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,410)