Filter records in PowerApps based on the owner of the record in Dynamics 365 CE

By | June 10, 2019

Introduction

In today’s blog we will explore how to filter records in PowerApps of Dynamics 365 CRM based on the logged in user in the PowerApps.

Now I have created a default Canvas app for Account entity. As you can see in below screenshot, the list contains all the account records belonging to different users:

PowerApps Dynamics 365

Now we have to filter the records based on the logged in user in PowerApps. To achieve this please follow the below steps:

1. Create a default Canvas app for appointment entity by using Dynamics 365 CRM. You can refer our previous blog here.

2. Now, edit the “Item” property of BrowseGallery:

SortByColumns(

Filter(

Accounts,

Owner = LookUp(

Users,

‘User Name’ = User().Email,

User

)

),

“emailaddress1”,

“address1_city”,

“name”,

If(

SortDescending1,

Descending,

Ascending

)

)

Please see the screenshot below:

PowerApps Dynamics 365

The above formula filters the account records by implementing the condition if ownerid is equal to the logged in user by using the function User() in PowerApps.

The User() function in PowerApps returns the information as Email, Full Name and Image about current logged in user in PowerApps.

You can refer this blog to gets more details.

3. Now log in to the other user and you will see the app contains those account records which belongs to the user:

PowerApps Dynamics 365

Conclusion

By implementing the above steps we can filter records of Dynamics 365 CRM in PowerApps based on the owner of the records.

70% of global 2000 companies apply gamification to improve productivity and returns!

Gamifics365 – Spin the magic of games within Microsoft Dynamics 365 CRM to improve user adoption, enhance productivity, and achieve company goals!

6 thoughts on “Filter records in PowerApps based on the owner of the record in Dynamics 365 CE

  1. Eatsam Danish

    Hi I am trying to filter records for example My Active accounts, I have used the following formula but it is not showing the results for My Active Accounts. I tried to use the formula in the blog above and it is not returning the results.

    SortByColumns(Search(Filter(Accounts,If (DropdownAccount.SelectedText.Value=”My Active Accounts”,’Status Reason Label’=”Active” && Owner = Lookup(Users, ‘Full Name’ = User().Email, User), DropdownAccount.SelectedText.Value = “Active Accounts”,’Status Reason Label’=”Active”,DropdownAccount.SelectedText.Value=”Inactive Accounts”,’Status Reason Label’=”Inactive”,DropdownAccount.SelectedText.Value=”All Accounts”,’Status Reason Label’=”Active”,’Status Reason Label’=”Inactive”)),TextSearchBoxAccount.Text,”name”),”name”,If(SortDescending1,Descending,Ascending))

    1. inogic

      You can simply edit the formula on item property of the gallery to filter active accounts as below:

      SortByColumns(
      Filter(
      Accounts,
      If(
      Dropdown1.SelectedText.Value = “My Active Accounts”,
      statecode = 0 && Owner = LookUp(
      Users,
      ‘User Name’ = User().Email,
      User
      )
      )
      ),
      “emailaddress1”,
      “address1_city”,
      “name”,
      If(
      SortDescending1,
      Descending,
      Ascending
      )
      )

      Please refer the screenshot below:

      PowerApps

      The above formula will filter the accounts on “statecode” based on the dropdown selected text and current user.

      Let us know if you need any further assistance on this.

      Hope this helps!

      Thanks!

  2. Terry

    I am trying to do something similar with Leads. I’d like to have the display screen only show leads that are open and owned by the current user. If something is entered into the Searchbox, I want it to look at the fullname or companyname fields on the Lead and only return open records owned by the current user that match the search.

    Is this possible? Can you help? I would really appreciate ANY assistance you can provide as I am very frustrated at this point!

    1. Inogic

      Below is the filter query to filter the records in canvas app based on the current logged-in user.
      Filter(
      [@Leads],
      ‘Status’ = ‘Status (Leads)’.Open,
      TextSearchBox1.Text in Email || TextSearchBox1.Text in Name,
      AsType(
      Owner,
      [@Users]
      ).’Full Name’ = User().FullName
      )

      Also make sure you have USERS entity added as a connection.
      for more details information on AsType function in canvas app you can follow the below referred link:
      https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-astype-istype

      Thanks!

  3. sravanthi

    Hi, I am facing delegation warning on the formula : its says “Lookup” part on this formula may not work properly on the large datasets, Please help me how to overcome delegation.
    I tried to set powerapp settings value from 500 to 2000, but it didn’t work.
    Thank you.

Comments are closed.