Activity Forums Salesforce® Discussions Can report data be accessed programatically?

  • Gourav

    Member
    August 26, 2016 at 8:23 am

    Hi Tanu,

    Yes, you can accessed reports in apex.

    Firstly, you can get a list of reports in XML from: https://instance.salesforce.com/servlet/servlet.ReportList (replacing instance with the actual server instance, such as na1)

    Once you have extracted the required report Id (00O key prefix) you can then request the report data in either CSV or HTML.

    CSV https://instance.salesforce.com/00Ox0000000xxxx?export=1&enc=UTF-8&xf=csv
    HTML https://instance.salesforce.com/00Ox0000000xxxx?export=1&enc=UTF-8&xf=xls (Last time I checked this was HTML rather than a native Excel file format. Excel does the conversion when it is opened).

    As for working with the CSV output, I found Parse a CSV with APEX but I haven't tested it yet.

    If you want to get fancy, you can set filters for the report too. See BUILDING SALESFORCE CUSTOM LINKS - Linking to Reports for the pv0, pv1... query string parameters.

    Reference:

    Progmatic Access to Salesforce.com Reports This post was from 2006, but shows that the approach has been working for a several years now. That still doesn't mean it might not work tomorrow.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos