I created sample PCF control for dataset.As I already know that update method call when we click on show chart or click on refresh button from ribbon bar.I want a ways from which it easy to identify update method call because of show chart .
So is there any way to identify that.
No information is sent alongside the trigger so you won't know what triggered it (updateview is called whenever anything changes so it's could just as easily be because the browser window has changed size)
I suspect if the user has clicked a graph and changes the view the dataset available to the PCF component will be changed / refreshed (I don't have time to test that process). If that's the case you could keep a track within the PCF of the record count of the initial dataset and the count of the new dataset and a change in record count as your identifier.
@ben-thompson is correct. When you click on a chart segment/refresh button/quick find/view selector, the data is simply reloaded and piped to the updateView - you don't get notified of why it has changed - only that it has changed.
I do a record count and row by row comparison on the sortedRecordIds to establish if any of the data has been changed.
Hope this helps
Maybe you can make use of context.updatedProperties that are passed with the updateView method.
This is documented in the sdk, but is not really documented what can be the content of this Array of strings.
I've made a short check, and saw that:
- after change the view selector you get : ["layout"]
- after change the filter: ["dataSetGrid", "parameters"] or ["dataSetGrid", "parameters", "dataset"]
- after refresh button: ["dataSetGrid", "parameters"]
- after open a chart: ["layout", "dataSetGrid", "parameters", "dataset"]
Also there are a lot calls with empty array passed in between.
I think is not very safe to rely on this, is depends what you need to do, but maybe it helps.
If it's documented in the SDK then it's the go to solution and I suspect the documentation is lacking because it may not be populated in all circumstances.
I suspect a combination of this and checks against the old and new datasets would be the ideal approach.
My question is also the same. I tried your solution it works fine for me but now because of the update in Dynamics CRM(Open Advanced Filtering Panel)get added above the PCF grid control. When I filter the data using the "Open Advanced Filter Panel" grid control gets a load from start and this time new count of record occurs that is actually not the original count of record. In this situation compare old count and new count logic not work.
Please provide me a solution to solve this problem.
Hi @Harry_Potter ,
Do you change the filtering in your code?
It's true that the "init" method is called after applying or removing this "Advanced Filter", and the "updateView" directly after that (more than once). But in my case I get the right number of records. That's not the number of records I have filtered using code inside my PCF, but the number of records applied by "Advanced Filter". When the "Advanced Filter" is removed, then all the records from the view are provided.
Do you experience something else?
In my case also working is the same. But I want the total number of record count and the advance filter record count for compare. When the advance filter gets apply where I will get the original total record count.
Hi @Harry_Potter ,
On my side, I don't rely on record number, since the record count can stay the same but the records might be different.
I just let React handle the changes, and I'll use React.memo for unnecessary rendering optimization.
In updateView method, I ignore the calls when the context.updateProperties contains "layout", and that way works pretty good.
Maybe you have a special case, since you need the number of records. If you have to rely on record count, you can maybe use webApi to make an aggregate fetch. Might be an unusual approach though.
Hope it helps.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.
Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.