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
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
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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

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