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.
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.
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.
@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?
Thanks much appreciated worked great for me!
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.
WarrenBelz
69
Most Valuable Professional
mmbr1606
51
Super User 2025 Season 1
MS.Ragavendar
36