I having checkbox on my PCF control on click of which we are using setSelectedRecordIds to set the id of selected record to show ribbon buttons. But somehow from past one week when this method is triggered it calls the update view method which refreshes my control.
In the screenshot we can see in updated properties selecteditems.
Anybody facing same issue ?
Solved! Go to Solution.
when setting selected records updateView should be called since it is changing the dataset state.
However, setting selected records wasn't causing updateView before which was incorrect.
This issue been recently fixed. That's why you see the change in the behavior.
Based on documentation for updateView, this method will be called for any data or metadata changes and the controls should assume updateView will be called multiple times during lifecycle of the control. Best practice is to use updatedProperties and other methods on dataset to decide if the control need to react (re-render) on a call to updateView or not.
We are facing the same issue in our project.
On click of an element, we select the record using setSelectedRecordIds but this method triggers the updateView method and resulting in the reset of the selection of records. We also notice that this issue is occurring in some CRM regions like crm4. On CRM8 and CRM region it is working as expected.
Some of our clients have raised this issue to us.
@AnqiChen @HemantG could you please help us out?
Thanks in advance.
Hi @Bhuvita , Hi @sheldoncopper73 ,
I can see that the updateView is called after setSelectedRecordIds, but I cannot say if that is new.
In the context.updatedProperties I see ["SelectedItems"], and the dataset.getSelectedRecordIds() still has the selection.
Does getSelectedRecordIds return [] to you, when updateView is called.
My dataset PCF still works, but since the updateView is called often, I use React.memo around my React component and render only if the dataset or container width or height changes. I'm not sure if I'm lucky on my environment (crm4 region), or the React.memo does the job for me.
Hope it helps!
Kind regards,
Diana
As a workaround you can try setting a private property to flag that update view should not run when you are setting selected record IDs.
when setting selected records updateView should be called since it is changing the dataset state.
However, setting selected records wasn't causing updateView before which was incorrect.
This issue been recently fixed. That's why you see the change in the behavior.
Based on documentation for updateView, this method will be called for any data or metadata changes and the controls should assume updateView will be called multiple times during lifecycle of the control. Best practice is to use updatedProperties and other methods on dataset to decide if the control need to react (re-render) on a call to updateView or not.