Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apex Custom data provider not working #74

Closed
mmzoughi90 opened this issue Jul 8, 2021 · 4 comments · Fixed by #90
Closed

Apex Custom data provider not working #74

mmzoughi90 opened this issue Jul 8, 2021 · 4 comments · Fixed by #90
Labels
bug Something isn't working

Comments

@mmzoughi90
Copy link

Hi,

I have this custom data provider that I use in a Lightning page just to test showing a pie chart with the lightning component and the apex custom data provider and I have an error:
The apex class:
public without sharing class AP18_TSCustomPieDataProvider extends lwcc.ChartDataProvider {
public Object initParameter;
public override void init(final Object initParameter) {
}
public override List<lwcc.ChartDataProvider.ChartData> getData() {
final List<lwcc.ChartDataProvider.ChartData> chartDatas = new List<lwcc.ChartDataProvider.ChartData>();
lwcc.ChartDataProvider.ChartData aChartData = new lwcc.ChartDataProvider.ChartData();
aChartData.labels = DEMO_LABEL;
aChartData.detail = DEMO_DATA;
aChartData.bgColor = DEMO_COLOR;
chartDatas.add(aChartData);
return chartDatas;
}

public static final List<String> DEMO_LABEL = new List<String>{'Test1','Test2'};
public static final List<Decimal> DEMO_DATA = new List<Decimal>{
        10,
        20
};
public static final String DEMO_COLOR = 'rgba(0,0,0,0.5);';

}

And the error message is: "Attempt to de-reference a null object"

Who is the bug affecting? = any user

What is affected by this bug? = pie chart rendering

When does this occur?= always

Where on the platform does it happen? = on the chart on the lightning page

How do we replicate the issue? = it happend always

Thanks,

@Mock1
Copy link

Mock1 commented Jan 12, 2022

I also can't get the above, or the demo sample in the repository, to work.

@victorgz
Copy link
Collaborator

Hi @Mock1 and @mmzoughi90. I've been able to reproduce the error from my side too and I am now working to look for an explanation and a fix for it.

Meanwhile, there is one workaround that seems to work: change the access modifier of the class extending lwcc.ChartDataProvider to global. In the example above it would be: global without sharing class AP18_TSCustomPieDataProvider extends lwcc.ChartDataProvider { ... }. You can keep public access level in the methods.

Can you please let me know if this works for you? Thanks !

@victorgz victorgz added the bug Something isn't working label Jan 13, 2022
@Mock1
Copy link

Mock1 commented Jan 13, 2022

Maybe @mmzoughi90 can test the global edit. I was able to narrow it down to just the managed package, and I suspect it's tied into the namespace. I also put a debug statement in the init method, and it never fired, so I think the ChartBuilderController (line 19) is failing to fetch the class.
I uninstalled the package, and just deployed the code here unmanaged, and it suddenly works. But sadly, now I can't really test the edit suggested. Changing it to global does not break anything in the unmanaged code, but I'm not going to reinstall to try the fix in the managed package.

I think that checks out with the public->global change, I don't think the package can "see" the class in another namespace without it being global.

@eclarke12
Copy link

Hi @Mock1 and @mmzoughi90. I've been able to reproduce the error from my side too and I am now working to look for an explanation and a fix for it.

Meanwhile, there is one workaround that seems to work: change the access modifier of the class extending lwcc.ChartDataProvider to global. In the example above it would be: global without sharing class AP18_TSCustomPieDataProvider extends lwcc.ChartDataProvider { ... }. You can keep public access level in the methods.

Can you please let me know if this works for you? Thanks !

Thanks for this, global access modifier worked for me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants