cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Office365user.MyProfile().department

Hi guys,

 

I created an app and in my app there is a gallery which is showing my employees. Imagine that I have 5 managers who will use my app. So there are 5 EmployerID, manager1 = EmployerdID 001, manager2 = EmployerdID2 etc.

 

Now I am using this formula in the Item property of my gallery: 

SortByColumns(Search(Filter('[dbo].[Employee]_1',Office365Users.MyProfile().Department=EmployerId),TextSearchBox1_1.Text,"EmployeeId","FirstName","Lastname"),"FirstName",If(SortDescending1,Descending,Ascending))

As you can see MyProfile().Departement = EmployerID. So every manager sees only his own employees which is belong to. 

 

But there is also a CEO which must have to see all the employees of the 5 managers. How can I achieve this? Or how can I achieve that for example manager 1 can see the employees of manager2 and3?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Office365user.MyProfile().department

Hi @Anonymous ,

 

Please try below formula instead:

SortByColumns(Search(If(User().Email="CEOEmailAddress",Filter('[dbo].[Employee]_1',Or(Office365Users.MyProfile().Department="001",Office365Users.MyProfile().Department="002",Office365Users.MyProfile().Department="003",Office365Users.MyProfile().Department="004",Office365Users.MyProfile().Department="005")),Filter('[dbo].[Employee]_1',Office365Users.MyProfile().Department=EmployerId)),TextSearchBox1_1.Text,"EmployeeId","FirstName","Lastname"),"FirstName",If(SortDescending1,Descending,Ascending))

In this formula, you use the User().Email function to check if the current logged in user is CEO or not. If current user is CEO, then it will show all the data for the 5 EmployerID.

 

For more information about User function, please refer to:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-user

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Highlighted
Community Support
Community Support

Re: Office365user.MyProfile().department

Hi @Anonymous ,

 

Please try below formula instead:

SortByColumns(Search(If(User().Email="CEOEmailAddress",Filter('[dbo].[Employee]_1',Or(Office365Users.MyProfile().Department="001",Office365Users.MyProfile().Department="002",Office365Users.MyProfile().Department="003",Office365Users.MyProfile().Department="004",Office365Users.MyProfile().Department="005")),Filter('[dbo].[Employee]_1',Office365Users.MyProfile().Department=EmployerId)),TextSearchBox1_1.Text,"EmployeeId","FirstName","Lastname"),"FirstName",If(SortDescending1,Descending,Ascending))

In this formula, you use the User().Email function to check if the current logged in user is CEO or not. If current user is CEO, then it will show all the data for the 5 EmployerID.

 

For more information about User function, please refer to:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-user

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,558)