apex Step Type Properties
Use to include custom Apex functionality in a dashboard to access Salesforce platform features that aren’t inherently supported in Analytics. For example, pull in data using any API, manipulate data using your Apex classes, or apply simple case statements or complex machine learning. You can even harness AppExchange for things like integrating Twitter with Analytics—all in a way that is familiar.
To set up an apex step, create an Apex class that returns data in a shape that Analytics can consume. And then define the step with the apex step type in the dashboard JSON. The step calls the Apex REST endpoint to return the data from the Apex controller class.
Like a soql step, the Apex controller can return tabular data. Unlike saql and soql step types, the apex step type doesn’t define the "strings", "numbers", and "groups" arrays. The Apex class response must declare these column types.
When you define an apex step, you can use a selection or results binding on the body parameter in the step JSON. You can also reference this step type in a results binding. This step type doesn’t support faceting. If you run a Analytics REST API query using an apex step, the query runs as the logged-in user. Each REST API query counts against the org’s API limits.
Note the following limitations with apex steps:
- If you include dashboards in a package,
apexsteps aren’t included. You must migrate the Apex classes separately. - The Android mobile app doesn’t support this type of step.
| Field Name | Description |
|---|---|
type | Step type. Set to apex. |
label | Step label, which is primarily used for display in the dashboard designer user interface. |
query | Query that returns the results. Can consist of the these parameters:
|
You want to display real-time stock data from a website in your dashboard. You want to fetch the data from an external API and add logic to determine the time of day for each stock price. Here’s the goal for this dashboard.

To create this dashboard, complete the following steps:
- Create the Apex controller class that gets the data from the stock website.
- Add the stock website to the allowed sites in Salesforce.
- Create the
apexstep in addition to the other dashboard widgets.
Define the Apex controller class and methods that return the stock price for different companies over time.
-
From setup, enter
Apex Classesin the Quick Find box, and select Apex Classes. -
Click New.

-
Add the following code.
-
Add two more Apex classes for
ApexStepRequestandApexStepResponseto support the Apex stocks class.The code for these classes, along with the stock step code, can be found in this public
AnalyticsApexStepsGitHub repo, in the/force-app/main/apex/commondirectory. This GitHub repo also contains other Apex step examples. -
Click Save.

To enable Apex to query external REST endpoints, allow the website in Salesforce.
-
From setup, enter
Remotein the Quick Find box, and select Remote Site Settings. -
Click New Remote Site.

-
Enter the remote site name and URL.

-
Click Save.
Manually define the apex step in the dashboard JSON to get the stock results from the Apex class that you previously created.
In the dashboard JSON, add the following apex step.
The apex step query contains the these parameters.
-
body— The binding retrieves the stock symbol when a company is selected in the toggle widget.
-
path— Specifies the REST API resource path to the Apex controller, as specified in theurlMappingof theRestResourceannotation on the Apex controller.
The dashboard shows four widgets. The toggle widget is based on a static step that maps predefined company names to stock symbols. The table widget and line chart use the apex step to retrieve the results. The text widget uses a binding to concatenate “Selected symbol:” and the stock symbol of the selected company in the toggle widget.
Here’s the final dashboard JSON.