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.

services

2 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))

    Reply
    1. inogic Post author

      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!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *