Activity Forums Salesforce® Discussions Can report data be accessed programmatically through Salesforce Apex?

  • Subhendu

    Member
    January 15, 2018 at 3:14 pm

    Yes Ratnakar, you can access SFDC report data via Reports REST API.

    Hope this helps.

    Thanks,
    Subhendu

  • PRANAV

    Member
    January 15, 2018 at 3:16 pm

    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.

  • Pulkit

    Member
    January 6, 2020 at 5:24 am

    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,

  • Pulkit

    Member
    January 6, 2020 at 7:10 am

    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.

Popular Salesforce Blogs