Activity › Forums › Salesforce® Discussions › Can report data be accessed programmatically through Salesforce Apex?
Tagged: Report Data, Report in Salesforce, Salesforce Apex, Salesforce Apex Class, Salesforce Apex Controller, Salesforce Apex Trigger, Salesforce Reports
-
Can report data be accessed programmatically through Salesforce Apex?
Posted by Ratnakar on January 15, 2018 at 2:26 PMCan report data be accessed programmatically through Apex?
Pulkit replied 6 years, 4 months ago 4 Members · 4 Replies -
4 Replies
-
Yes Ratnakar, you can access SFDC report data via Reports REST API.
Hope this helps.
Thanks,
Subhendu - [adinserter block='9']
-
Hi Ratnakar,
You can refer to the standard salesforce api guide and search “RUN REPORTS” for this. Or you can use the below piece of code.
// Get the report ID
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where
DeveloperName = ‘Closed_Sales_This_Quarter’];
String reportId = (String)reportList.get(0).get(‘Id’);// To run a report synchronously
Reports.ReportResults results = Reports.ReportManager.runReport(reportId, true);
System.debug(‘Synchronous results: ‘ + results);// To run a report asynchronously
Reports.ReportInstance instance = Reports.ReportManager.runAsyncReport(reportId, true);
System.debug(‘Asynchronous instance: ‘ + instance);Hope this helps you.
-
Hi @Pranav,
I want to see a report owned by an owner (report link on VF Page) when he/she logs in.
For Eg;- I have created a report and Report Owner is ‘X’. Now when X logs in and access the VF Page(Report Link is already added), and clicks on report link, he should be redirected to his report.
Similarly, when Y logs in and clicks on report link(on VF Page), he should be redirected to the report assigned to him.
Any information would be a great help.
Thanks,
-
Hi @Pranav,
I want to see a report owned by an owner (report link on VF Page) when he/she logs in.
For Eg;- I have created a report and Report Owner is ‘X’. Now when X logs in and access the VF Page(Report Link is already added), and clicks on report link, he should be redirected to his report.
Similarly, when Y logs in and clicks on report link(on VF Page), he should be redirected to the report assigned to him.
Any information would be a great help.
Thanks,
Log In to reply.