You need to sign in to do that
Don't have an account?
lali
Runreport method gives a compilation error
Hi All,
Had the following simple code like it is shown in the Example in salesforce but gives a compilation error saying 'Initial term of field expression must be a concrete SObject: List<Report>'
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where
DeveloperName = 'BSC_Accounts'];
String RID = (String)reportList.get(0).get('Id');
// Run the report
Reports.ReportResults results = Reports.ReportManager.runReport(RID, true);
System.debug('Synchronous results: ' + results);
running the same code in 'Execute Anonymous Window' works just fine.
Need Help...
Thank you :)
// Get the report ID
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where
DeveloperName = 'BSC_Accounts'];
String RID = (String)reportList.get(0).get('Id');
// Run the report
Reports.ReportResults results = Reports.ReportManager.runReport(RID, true);
System.debug('Synchronous results: ' + results);
Had the following simple code like it is shown in the Example in salesforce but gives a compilation error saying 'Initial term of field expression must be a concrete SObject: List<Report>'
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where
DeveloperName = 'BSC_Accounts'];
String RID = (String)reportList.get(0).get('Id');
// Run the report
Reports.ReportResults results = Reports.ReportManager.runReport(RID, true);
System.debug('Synchronous results: ' + results);
running the same code in 'Execute Anonymous Window' works just fine.
Need Help...
Thank you :)
// Get the report ID
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where
DeveloperName = 'BSC_Accounts'];
String RID = (String)reportList.get(0).get('Id');
// Run the report
Reports.ReportResults results = Reports.ReportManager.runReport(RID, true);
System.debug('Synchronous results: ' + results);
Please try to use updated below code. Please mark this answer as solution if this resolved your issue.
Hi Amit,
I tried that earlier. that didn't work. I even tried hardcoding the reportid and that didn't work either .it gives compilation error at line 5.
I have this code in a vf page controller extension class . I want to execute this code when the user picks a report from a select list( where I show all the reports) on the onchange event of selectlist tag, my intention is to get all the accountids from the report and put them in the list and later work with them.
do you know if we can have this code in the controller class of a vf page?
thanks
lalitha
sorry for being late on this. thanks a lot for helping out. to make it easier , I seperated the code from my original page to make it easier.
you can just paste the code as it is to the vf page and the controller
at line no 31 where I commented the code , if you uncomment it and try to compile will give you the error.
vf page:
<apex:page controller='vfc_testclass'>
<apex:form>
<apex:pageBlock>
<apex:selectList value="{!reportid}" size="1" onchange="refreshFields(this.value);">
<apex:actionFunction action="{!resetSelectedText}" name="refreshFields" reRender="fieldSet" immediate="true">
<apex:param name="theSelreport" value="" assignTo="{!reportid}"/>
</apex:actionFunction>
<apex:selectOptions value="{!optionlist }"/>
</apex:selectList>
<apex:commandButton action="{!showReport}" status="remove-as-status" value="Show Report"/>
<apex:commandButton action="{!associateReport}" status="remove-as-status" value="Associate Accounts From Report"/>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class vfc_testclass {
public list<selectoption> list1 = new list<selectoption>();
public list<report > reports = new list<report >();
public String reportid {get;set;}
public list<selectoption> getoptionlist()
{
reports = [select id, Name from report where name like 'BSC%' limit 100];
list1.add(new selectoption('--Select options--', '--Select options--'));
for(report R:reports)
{
list1.add(new selectoption(R.id,R.Name));
}
return list1;
}
public void resetSelectedText()
{
system.debug('ReportID: ' + reportid);
//string reportid = '00OU00000027woq';
// Get the report ID
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where
DeveloperName = 'BSC_Accounts'];
system.debug('reportList' + reportList );
String RID = (String)(reportList[0].Id);
// Run the report
//Reports.ReportResults results = Reports.ReportManager.runReport (RID, true);
//System.debug('Synchronous results: ' + results);
}
public PageReference showReport(){
PageReference pg = new PageReference('/' + reportid);
pg.setredirect(true);
return pg;
}
public void associateReport(){
//Associate the accounts to the Account set.
}
}
I found out that I declared a variable 'reports' at line no 3 in the controller which is a reserved keyword but gave the error at line
Reports.ReportResults results = Reports.ReportManager.runReport (RID, true); which was confusing.
finally by changing the reports variable name solved the issue.
thanks
is there any document on how we can parse the data from the reportresults. I am trying to get all the accountds into a list from the report result.
Thanks
lalitha