1

I am using <analytics:reportChart/> tag inside a visualforce page where the reportId attribute value is dynamically retrieved from associated Controller. The controller also runs the report synchronously after adding a filter value to the report.

Visualforce Page

<apex:page sidebar="false" controller="ReportController">
    <analytics:reportChart reportId="{!ReportId}"></analytics:reportChart>
</apex:page>

ApexClass

public class ReportController 
{
    public string getReportId()
    {
        string reportID = '';
        List<Report> reportList = [select ID, DeveloperName from Report 
                                  where DeveloperName = 'myTestReport'];
        reportId = (string)reportList.get(0).get('Id');

        Reports.ReportDescribeResult myReportResult = Reports.ReportManager.describeReport(reportId);
        Reports.ReportMetadata myReportMetaData = myReportResult.getReportMetadata();

        Reports.ReportFilter myFilters = myReportMetaData.getReportFilters()[0];
         system.debug('--------->'+myFilters);

        //set the filter value
        myFilters.setValue('OL-000040');
        Reports.ReportResults results = Reports.ReportManager.runReport(reportId, myReportMetaData);

        return reportID;
    }
}

I see that the report is running successfully but the chart that is getting displayed is NOT capturing the filtered data from the report. Anyone guide me through the right way to achieve this?

2
  • Did you find answer for this ? – brahmaji tammana Sep 12 '17 at 12:59
  • @brahmajitammana Nope, I did not. – sam_s Sep 12 '17 at 15:27
0

Replace second last line with following and try again

Reports.ReportResults results = Reports.ReportManager.runReport(reportId, myReportMetaData,true);
1
  • Please add some explanation of why this solution is different and what it fixes. – Adrian Larson Oct 16 '17 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.