-
How can I access the recordId which is passed by the LWC in a CustomDataProvider? I looked at the DemoDataProvider but see no mention of recordId. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @mrcdsouza, Yes the The code passes the You could have a custom data provider that store this input and use it in the global inherited sharing class SampleDataProvider extends ChartDataProvider {
protected String recordId;
public override void init(final Object initParameter) {
this.recordId = (String) initParameter;
}
public override List<ChartDataProvider.ChartData> getData() {
final List<ChartDataProvider.ChartData> chartDatas = new List<ChartDataProvider.ChartData>();
// Use this.recordId;
return chartDatas;
}
} I hope it helps |
Beta Was this translation helpful? Give feedback.
-
@scolladon @mrcdsouza I'm using LWCC in my custom LWC component and I want to get the label and value for the clicked bar chart in my JS. Could you please how to do this? |
Beta Was this translation helpful? Give feedback.
Hi @mrcdsouza,
Yes the
DemoDataProvider
does not show how to use therecordId
parameter.The code passes the
recordId
value when the handler is set using thechartBuilder
LWC component.This code then call the backend with this value as input (casted to Object)
The backend then call the init method of your custom handler with this
input
parameterThe init method is abstract so it means its implementation is at your discretion.
You could have a custom data provider that store this input and use it in the
getData
method