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
1 Asked on January 29, 2021 by j-0
2 Asked on January 28, 2021 by samdev
excel javascript lightning lightning aura components lightning experience
1 Asked on January 28, 2021 by user87438
1 Asked on January 28, 2021 by javanoob
1 Asked on January 27, 2021 by shira-freed
1 Asked on January 27, 2021 by shobhit-saxena
0 Asked on January 26, 2021 by ifabiodlc
1 Asked on January 26, 2021 by dearbrother
2 Asked on January 26, 2021 by sitansu-pradhan
1 Asked on January 25, 2021 by user2957592
4 Asked on January 25, 2021 by kd7iwp
1 Asked on January 25, 2021 by valarie-simmons
0 Asked on January 24, 2021 by khushi
1 Asked on January 24, 2021 by walker
2 Asked on January 24, 2021 by zufra
0 Asked on January 23, 2021 by hermann-our
1 Asked on January 23, 2021 by alex-xiong
lightning design system lightning experience lightning web components popover slds
1 Asked on January 21, 2021 by mauforsalesforce
Get help from others!
Recent Questions
Recent Answers
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP