Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CustomDataProvider recordId #137

Answered by scolladon
mrcdsouza asked this question in Q&A
Discussion options

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.

You must be logged in to vote

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

Comment options

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

You must be logged in to vote
1 reply
Comment options

Thank you Sebastien for the answer and providing the LWC.

Answer selected by mrcdsouza
Comment options

@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?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /