Lightning Web Component setState Method

Use the setState method to set the state of the rendered Lightning web component for CRM Analytics dashboards.

Arguments 

Argument NameDescription
stateThe state to update the CRM Analytics dashboard component with.

Example 

Add your implementation of the setState call into the wrapper Javascript and HTML for your component.

To use the communityDashboard component, replace wave-wave-dashboard-lwc with wave-community-dashboard.

Note

The HTML for the component:

1<template>
2  <lightning-button variant="brand" label="Set Dashboard State" title="Set State Action" onclick={setState} class="slds-m-left_x-small"></lightning-button>
3  <wave-wave-dashboard-lwc dashboard="0FK5B000000XiK14AK" height="1000"></wave-wave-dashboard-lwc>
4</template>

The Javascript for the component, which implements setState():

1import { LightningElement } from 'lwc';
2
3export default class DashboardWrapper extends LightningElement {
4  _state = {};
5
6  setState () {
7    const dashboard = this.template.querySelector('wave-wave-dashboard-lwc');
8    dashboard.setState(this._state);
9    console.warn("setState complete");
10  }
11}

The state can be set dynamically from user input or from another dashboard’s state. For the complete dashboard state structure, refer to the Analytics Dashboard JSON Reference guide.

See Also