cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
al4629740
Level: Powered On

Filter datasource by user

We have several difference users in Office 365.  When each access one particular table in the data source, we want them to have access only to data that relates to them and not view other information that does not concern them.  If we have a column that specifies which user that record belongs to, is there a way to filter that information to ony that user once they log into their powerapp?  Basically, is there a way for their username/login to be used to filter the data that they are able to view?

1 ACCEPTED SOLUTION

Accepted Solutions
CurranD
Level: Powered On

Re: Filter datasource by user

User() pulls up the current user who's logged in, then the .FullName would fetch the full name for that user (Firstname Surname).

 

So Jane Doe with the email jd@email.com:

  • User().FullName - "Jane Doe"
  • User().Email - "jd@email.com"

 

EDIT: Here's the Microsoft Docs page for this: https://docs.microsoft.com/en-us/powerapps/functions/function-user

View solution in original post

8 REPLIES 8
ajs1
Level: Powered On

Re: Filter datasource by user

my bad wrong thread

CurranD
Level: Powered On

Re: Filter datasource by user

If you have a field the same as the users 'Full Name' you should be able to filter by User().FullName or even User().Email

 

Never tried it but should work?

 

E.g.

 

Filter(Collection, OwnerField = User().FullName)

al4629740
Level: Powered On

Re: Filter datasource by user

Is User().Email a system control that pulls up whomever is currently logged in?

CurranD
Level: Powered On

Re: Filter datasource by user

User() pulls up the current user who's logged in, then the .FullName would fetch the full name for that user (Firstname Surname).

 

So Jane Doe with the email jd@email.com:

  • User().FullName - "Jane Doe"
  • User().Email - "jd@email.com"

 

EDIT: Here's the Microsoft Docs page for this: https://docs.microsoft.com/en-us/powerapps/functions/function-user

View solution in original post

al4629740
Level: Powered On

Re: Filter datasource by user

Very cool.  In the profile in Office 365, there is a section for Department and Office.  Could I filter the data they view by those variables also?

al4629740
Level: Powered On

Re: Filter datasource by user

Very cool.  In the profile in Office 365, there is a section for Department and Office.  Could I filter the data they view by those variables also?

CurranD
Level: Powered On

Re: Filter datasource by user

Nope, not with the User() command as that only fetches data that Powerapps needs.

 

If you wanted to filter by other sections of Office 365 you'd have to add a connection to Office365 in your app.

 

Can find an overview of doing that here: https://powerapps.microsoft.com/uk-ua/tutorials/connection-office365-users/

 

You can then use any of the following:

  • Office365Users.MyProfile().Department
  • Office365Users.MyProfile().DisplayName
  • Office365Users.MyProfile().GivenName
  • Office365Users.MyProfile().Id
  • Office365Users.MyProfile().JobTitle
  • Office365Users.MyProfile().Mail
  • Office365Users.MyProfile().MailNickname
  • Office365Users.MyProfile().Surname
  • Office365Users.MyProfile().TelephoneNumber
  • Office365Users.MyProfile().UserPrincipalName
  • Office365Users.MyProfile().AccountEnabled

Again not tested filtering based off these values but theoretically it should work 🙂

 

KevB
Level: Powered On

Re: Filter datasource by user

Hi I have tried this and it makes sense and works thank you. I would like to take this one stage further though and...

 

My issue is that I am trying to filter an existing data list by a column called "Country".

 

Issue 1

On the edit screen where the in country person adds a new line of data and completes the new data input by pulling down choice fields, I cannot get the pull down for "Country" to only show their Country it shows them all countries in the list. 

 

I have a list of countries and a list of users assigned to the countries so i can build a separate list to contain these if required to do a look up to or link back to?  

 

Issue 2

My master data list is built and linked to a PowerApp and everything works as it should apart form when I try and apply a filter to only show the user their Country data - I either get all the data or nothing at all.

 

Can you help on this at all? I can provide any details required as I have been trying to do this for opver a week.

 

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Kudoed Authors
Users Online
Currently online: 276 members 5,325 guests
Please welcome our newest community members: