Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
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.

  • mKaddoura255 Profile Picture
    16 on at
    Re: Multi Company Management On PowerApps

    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.

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Multi Company Management On PowerApps

    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
    Re: Multi Company Management On PowerApps

    @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?

  • mKaddoura255 Profile Picture
    16 on at
    Re: Multi Company Management On PowerApps

    Thanks much appreciated worked great for me!

  • Verified answer
    cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Multi Company Management On PowerApps

    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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 69 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 51 Super User 2025 Season 1

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 36

Overall leaderboard