cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Belasor
Helper III
Helper III

Calendar is emtpy at start

Hi all,

 

I´m currently building a custom calendar from the "Calendar" Template. It is available under Home->New Screen.

However I´m currently having the problem, that when I open up the app, I´m always getting the view from Picture 1.

I always need to choose the "Calendar" in the dropdown. After that it looks like it supposed to be. I want to hide the dropdown, unfortunately I can´t because of the blank view.

 

How can I resolve that problems? Any ideas?

 

BR

 

Picture 1

errorpa.png

Picture 2

errorpa2.png

1 ACCEPTED SOLUTION

Accepted Solutions
iAm_ManCat
Super User
Super User

Hi @Belasor 

 

Its actually the OnSelect action of the dropdown that is setting and collecting the date events - this is why its not there by default.

 

On your Screen's OnVisible, you can put that same OnSelect code and replace the Self.Selected with YourDropdownName.Selected  (see below) - then you can hide the dropdown for this. However those with more than one calendar will no longer be able to change their calendar...

 

/*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, Microsoft365Outlook.GetEventsCalendarViewV2(_myCalendar.Name, Text(_minDate, UTC), Text(_maxDate, UTC)).value);         
UpdateContext({_showLoading: false});         
Set(_calendarVisible, true)

 

Cheers,

Sancho

 
@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

6 REPLIES 6
iAm_ManCat
Super User
Super User

Hi @Belasor 

 

Its actually the OnSelect action of the dropdown that is setting and collecting the date events - this is why its not there by default.

 

On your Screen's OnVisible, you can put that same OnSelect code and replace the Self.Selected with YourDropdownName.Selected  (see below) - then you can hide the dropdown for this. However those with more than one calendar will no longer be able to change their calendar...

 

/*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, Microsoft365Outlook.GetEventsCalendarViewV2(_myCalendar.Name, Text(_minDate, UTC), Text(_maxDate, UTC)).value);         
UpdateContext({_showLoading: false});         
Set(_calendarVisible, true)

 

Cheers,

Sancho

 
@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Thank you very much, that is the solution.

Excellent, glad I could help - hope you have a great day!

 
@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Hello,

 

I have a small question, I just got today the information that currently there is a error coming up every time when using the PowerApp:

Office365Outlook.GetEventsCalendarViewV2 failed: The method 'GetEventsCalendarViewV2' has an invalid value for parameter 'calendarId'

 

OnVisible Code:

/*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; dropdownCalendarSelection2_2.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)

 OnSelect code:

/*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; dropdownCalendarSelection2_2.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)

 Did I made some mistakes?

Hello! It's maybe worth testing that the dropdown is actually visible and filled when that screen's onVisible loads, otherwise it won't be able to set the _mycalendar variable.

 

If you have enabled some of the preview features like delayed load etc then the dropdown may not have been created prior to the screen being visible for the first time - What I would look at doing is creating a hidden label on your App's First screen - have the label point to 

dropdownCalendarSelection2_2.Selected

 

So that the dropdown is loaded before the screen becomes visible.

 

Otherwise you could also look at testing with some users by making the dropdown visible for them and seeing if they can choose manually from the dropdown and if they still get the same error

 

Hopefully that helps! 

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Thank you sir, problem solved again :). Working now.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (4,131)