Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created September 15, 2019 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun12209/4fa9afdc2f5928572c9a351a412aaa89 to your computer and use it in GitHub Desktop.
Save arun12209/4fa9afdc2f5928572c9a351a412aaa89 to your computer and use it in GitHub Desktop.
ReportChartCntrl
public class ReportChartCntrl {
@AuraEnabled
public static User fetchReportChartSettings(){
User u = [select id,Report_Name__c,Chart_Type__c from User where id=:system.UserInfo.getUserId()];
return u;
}
@AuraEnabled
public static void updateSettings(String chartType, String reportName){
User u = [select id,Report_Name__c,Chart_Type__c from User where id=:system.UserInfo.getUserId()];
if(chartType !='' && reportName !=''){
u.Chart_Type__c = chartType;
u.Report_Name__c = reportName;
//update
update u;
}
}
@AuraEnabled
public static List<String> fetchReports()
{
List<String> options = new List<String>();
for(Report obj :[select id,name from report where Format='MATRIX' or Format ='Summary'] )//instead of BU_Project__c.Id pass actual id
{
options.add(obj.Name);
}
system.debug('Option Returned: '+options);
return options;
}
@AuraEnabled
public static String getReportData(string reportName){
//Using report id for example purpose
Report stdReport = [SELECT Id FROM Report WHERE Name =:reportName];
// Get the Report data
Reports.ReportResults reportReturned =Reports.ReportManager.runReport(stdReport.Id, true);
system.debug('Report Data: '+JSON.serialize(reportReturned));
//Return Report data in JSON serialize format.
return JSON.serialize(reportReturned);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment