web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Multi Company Manageme...
Power Apps
Answered

Multi Company Management On PowerApps

(0) ShareShare
ReportReport
Posted on by 16

I am trying to implement Multi company Management similar to BC in Power apps, I want to add to the user entity a sub grid of allowed companies and the user needs to have 1 as default.

When the user loads the CRM it will show him the records with the default company and he can always switch the company using the ribbon which till now all is fine, the issue is I need a way to filter the data for all pages which I did it using JS with SetFilterXML but the user will always have the ability to clear filter or I would have to turn it off.

Is there a way I could filter the user records retrievals from the beginning or set a filter in the view for each user without updating the saved query or any other way to achieve it??

What I am doing is possible because I saw someone who implemented this before.

I have the same question (0)
  • Verified answer
    cchannon Profile Picture
    4,702 Moderator on at

    Sure, you can implement your own Plugins on the RetrieveMultiple events of all those tables. RM is used on every list query, including every grid and subgrid. You can write your own .net plugins to execute during that query execution and filter the results based on whatever arbitrary logic you want.

     

    Some reference links:

    Write a plug-in (Microsoft Dataverse) - Power Apps | Microsoft Learn

    Sample: Modify query in PreOperation stage (Microsoft Dataverse) - Power Apps | Microsoft Learn

     

    But, be aware: RM events happen A LOT in Dataverse, way more than you probably think. So be very careful about performance impacts because putting plugins into these events can quickly degrade your overall app performance.

    Limit the registration of plug-ins for Retrieve and RetrieveMultiple messages - Power Apps | Microsoft Learn

  • mKaddoura255 Profile Picture
    16 on at

    Thanks much appreciated worked great for me!

  • mKaddoura255 Profile Picture
    16 on at

    @cchannon thanks again for your support.

    everything is working as expected but when I am on any view and I export data to excel, it exports all the data even the ones that I hide in RM operation. 

    Any idea on what can be done to prevent exporting all hidden data?

  • cchannon Profile Picture
    4,702 Moderator on at

    Oh, well that is very interesting... I would guess then that somehow the exportRetainedData Action is pulling the data without a normal Retrieve Multiple call?  I would not have expected that.

     

    Well, I guess then what you would have to do is to hide the normal Export to Excel buttons and replace them with your own that adds additional filter criteria to the filterXml parameter in that Action call.

     

    This is really surprising to me... Please keep me posted on what you find here.

  • mKaddoura255 Profile Picture
    16 on at

    Actually the export is pulling the data with a normal retrieve multiple as I discovered a solution to my issue which was a missing code in the RM plugin.

     

    I was casting the query from target to FetchExpression and if the value is not null then I do the filter needed.

     

    What I missed is that I need to try and cast it to a QueryExpression as well and add the filter and the export apparently runs as QueryExpression.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard