Salesforce Asked by VarunC on December 4, 2020
When using the component I’m receiving following error due to a chart not present in the report, be cause I verified Report exists and is public shared and report types are valid (Summary/Matrix), which are allowed Formats:
You can’t view the report chart because its report, report type, or
chart has been deleted.
So my query is, can we detect programatically, in Apex, if Report has an embedded chart in it?
Salesforce from Metadata API can be used to detect if report contains any chart or not. here is sample piece of code I am sharing which can give you a head start.
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
String[] reportNames = new String[]{};
//query the report
Report r : [Select OwnerId,NamespacePrefix,Name, Id, DeveloperName, Description
From Report where Id =:'YOUR REPORT id']
reportName = 'unfiled$public'+'/' + r.DeveloperName;
//add to report list so that multiple report data can be fetched.
reportNames.add(reportName);
for(MetadataService.Metadata reportData : service.readMetadata('Report',reportNames).getRecords())
{
MetadataService.Report reportData1 = (MetadataService.Report)reportData;
if(reportIdName.containsKey(reportData1.fullName) && reportData1.chart != null){
//CHART AVAILABLE
}
else
{
//chart not available
}
}
Answered by Himanshu on December 4, 2020
I believe you want to show a chart if there's a chart on the report, otherwise you don't want to show anything (not even the error).
If that's the case you can use the attribute hideOnError on the analytics:reportChart
component
if you set this attribute to true, if the report doesn't have a chart, then you won't see the error.
Answered by Vamsi Krishna Gosu on December 4, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP