cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PVLove
Helper II
Helper II

Calendar-Screen Template for Single User Email

Hello All!

I want to include the PowerApps Calendar-Screen Template in an app I'm preparing to build.  However, I want to display the calendar for a single User.  I found the following formula for the App > OnStart property.  Is it possible to hard code the User's email in this formula?

 

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 );
Set( _myCalendar,
LookUp(Office365Outlook.CalendarGetTablesV2().value, DisplayName = "{YourCalendarNameHere}" )
);
Set( _minDate,
DateAdd( _firstDayOfMonth, -( Weekday(_firstDayOfMonth) - 2 + 1 ), Days )
);
Set( _maxDate,
DateAdd(
DateAdd( _firstDayOfMonth, -( Weekday(_firstDayOfMonth) - 2 + 1 ), Days ),
40,
Days
)
);
ClearCollect( MyCalendarEvents,
Office365Outlook.GetEventsCalendarViewV3(_myCalendar.name,
Text( _minDate, UTC),
Text( _maxDate, UTC)
).value
);
Set( _calendarVisible, true )

 

Thank you in advance for any assistance.

Patti

2 REPLIES 2
poweractivate
Community Champion
Community Champion

@PVLove To hard code it just replace User().Email with a hard coded string instead.

 

If you meant how to abstract away User().Email to not repeat this again and again - you can do something like

Set(_userEmail, User().Email)

 

However, in Power Apps I think repeating User().Email again and again rather than abstracting it away in a separate variable is probably OK. In some cases, it may be desirable to repeat it. For example, if you set the variable, it may hold the value that is stale. Whereas calling it again and again makes sure it is the current value. If you prefer it though, you can set a variable for User().Email if you want to use the formula "User().Email" not more than once in the app.

 

 

I would suggest also you keep the recent changes to App.StartScreen and App.Onstart in mind if you started making a new app after around Oct 20, 2021 - related posts below:

 

Navigation in App.OnStart not allowed anymore (New App.StartScreen??) - Deep Link problem 

Deprecation of App OnStart? 

 

and this article: 

https://powerapps.microsoft.com/en-us/blog/app-startscreen-a-new-declarative-alternative-to-navigate...

 

 

Check if the above helps as general guidelines.

 

@poweractivate,

Thank you for the quick response.  I'm still learning PowerApps and not sure I understand your solution.  I thought that if I set User().Email that whomever views the form would see their calendar.  I only want a single User's calendar to be displayed when the form is accessed.  Before a request is submitted the Requestor needs to know if that User is available on the dates they need equipment installed.

Thanks!

Patti

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,227)