cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (5,368)