cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AraSaber12
Level 8

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
Community Support Team
Community Support Team

Re: Office365user.MyProfile().department

Hi @AraSaber12 ,

 

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
Community Support Team
Community Support Team

Re: Office365user.MyProfile().department

Hi @AraSaber12 ,

 

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
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

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