-
Notifications
You must be signed in to change notification settings - Fork 60
-
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.
All reactions
Hi @mrcdsouza,
Yes the DemoDataProvider does not show how to use the recordId parameter.
The code passes the recordId value when the handler is set using the chartBuilder 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 parameter
The 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
global inherited sharing class SampleDataProvider extends ChartDataProvider { protected String recordId; public override void init(final Object initParameter) { this.
Replies: 2 comments 1 reply
-
Hi @mrcdsouza,
Yes the DemoDataProvider does not show how to use the recordId parameter.
The code passes the recordId value when the handler is set using the chartBuilder 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 parameter
The 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
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.
All reactions
-
👍 1
-
Thank you Sebastien for the answer and providing the LWC.
Beta Was this translation helpful? Give feedback.
All reactions
-
@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.