Use the getState method to retrieve the current state of the rendered Aura component for CRM Analytics dashboards.
Arguments
| Argument Name | Description |
|---|---|
config |
The configuration for the getState call. This value is a JSON object that sets parameters for the call. For getState, the config is {}. |
callback |
The callback function to handle the getState payload response. See the next section for a basic callback example. |
Payload
| Payload attributes | Description |
|---|---|
pageId |
The current pageId of the dashboard. |
state |
The dashboard state. The state contains datasets, sObjects, sourceObjects, and steps. |
Example
Add your implementation of the getState call into the controller.js for your Aura component.
({
getState: function (component, event, helper) {
var dashboard = component.find("myDashboard");
var config = {};
dashboard.getState(config, function (result, error) {
if (error) {
console.warn("getState error: ", error);
}
if (result) {
component.set("v.dashboardState", JSON.stringify(result, null, 4));
}
});
},
});
In this example, the callback function handles success and error responses by setting component attributes with the response result. The getState result is passed to the component’s dashboardState attribute as a JSON string.
The callback result contains the payload with the pageId and the state attributes. Here’s a sample callback result.
{
"payload": {
"pageId": "#xxx##xx-x###-##xx-#x##-##x##x#x##x#",
"state": {
"datasets": {},
"sObjects": {},
"steps": {
"Step_1": {
"values": [],
"metadata": {
"groups": ["Field1__c"]
}
}
}
}
}
}
See Also