Displaying report data in Visualforce

The Salesforce analytics API allows reports to be executed and the contents retrieved from Apex code. Using this technique in a Visualforce controller decouples the dataset, allowing an administrator to change the report filter criteria, altering the data that will be displayed in the Visualforce page, without having to change any controller code.

In this recipe, we will create a Salesforce report that displays account names and their associated contact names. We will then execute this report from a Visualforce controller, parse the results, and display these in a Visualforce page.

Getting ready

This recipe makes use of a custom Salesforce report that must be created before the Visualforce page and its controller: ...

Get Visualforce Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.