CRM Analytics Aura Events - SelectionChanged Event
React to selections in your dashboard and get the row data for the selection.
The dashboard component also generates Lightning events when the user changes a selection. The payload for these events is effectively the row data for the current selection. Datasets can be from many sources, so the actual payload may only be meaningful when the user has knowledge of the datasets being used. This example shows how to receive and iterate through the payload, which is an array of objects representing the current selection.
This example uses the same dashboard used for the update event example, so be sure to follow those steps first.
Using the Developer Console, create an Aura component named recordView. Copy the following markup into the component.
Add a Controller (recordViewController.js) to the bundle and copy the following JavaScript into it:
This example references recordId, an Opportunity record identifier. If you don’t use this in your dashboard, substitute a different field.
Payload data can contain other objects, each in turn containing key-value pairs. For example, aside from the Id, you can also get the noun (for example, “dashboard”) and the verb (for example, “selection”).
Add a Style (recordView.css) to the bundle and copy the following CSS into it:
For a better experience in Lightning App Builder, add a Design (recordView.design) to the bundle and paste in the following:
The page you created using Lightning App Builder should now show the Record View component in the palette. Drag this component onto the page, then save the page.
Go back to Lightning Experience, and make a selection in your CRM Analytics Dashboard component. The corresponding Salesforce Opportunity record (or the record type you specified in recordViewController.js) will be displayed in the newly added component.
For more information about Aura events and other Lightning development features, see the Lightning Aura Components Developer Guide.