cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Way to find pcf control update method call because of we click on show chart in Dynamics CRM

Hi,

 

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.

 

Thanks

 

8 REPLIES 8
ben-thompson
Solution Sage
Solution Sage

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.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

@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

DianaBirkelbach
Super User
Super User

Hi @Anonymous 

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.

 

Best regards,

Diana

Kind regards,
Diana
----------
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

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.

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".

Hi,

  

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.

 

Thanks

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?

 

Kind regards,

Diana

Kind regards,
Diana
----------
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Hi Diana,

 

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.

 

Thanks!

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.

 

Kind regards,

Diana

 

 

Kind regards,
Diana
----------
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

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.

Users online (3,113)