Created
September 15, 2019 16:57
-
-
Save arun12209/4fa9afdc2f5928572c9a351a412aaa89 to your computer and use it in GitHub Desktop.
ReportChartCntrl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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