Using Ananlytics API in Apex with the help of Reports.ReportsManager Object and its methods, I am retrieving data from a report.
when I try to run the report using the following :-
Reports.ReportInstance instance = Reports.ReportManager.runAsyncReport(reportId,reportMd, true); System.debug('Asynchronous instance: ' + instance); //Get the Async report instance results Reports.ReportInstance instance1 = Reports.ReportManager.getReportInstance(instance.getId()); Reports.ReportResults results = instance1.getReportResults();
I am getting the following error while loading on Page :
"Content cannot be displayed. The report results aren't available because the instance has not finished running."
Attribution to: user8110
Possible Suggestion/Solution #1
believe you are trying to get the report results before the report is fully run. since you are using runAsyncReport method you have to do kind of polling on the report status and get the results once its run.. this blog from Peter Knolle has code sample on using async http://peterknolle.com/asynchronous-reports-with-the-analytics-api-in-apex/
the other option is to use one of the runReport synchronous methods in the ReportManager class. http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_class_reports_reportmanager.htm
Attribution to: Vamsi Krishna
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33801