1

Currently we have a dashboard component in Home page where users can select the dashboard they would like to view in Salesforce Classic. now we are migrating a set of users to Lightning. Is there anyway we could reproduce the same in Lightning? Currently i dont see option for end users to select the dashboard of their choice in home page .

Are there any possibilities of showing a dashboard inside a Custom Component?

1

While there does not seem an out of the box way to achieve this, but you can achieve this using a custom lightning component not really to embed the dashboard in the component itself but an approach to navigate to the dashboard.

For navigating to the dashboard, what you can do here is to utilize force:navigateToURL event to navigate to a particular dashboard. The custom lightning component will display all applicable dashboards say in a select option, where you map their respective ids. And upon selecting the respective dashboard, you just have the event navigate to it. It just depends on how you want the UX to be displayed, but ultimately using force:navigateToURL can be utilized to achieve the use case.

As an example, this is how your component and JS controller will look like.

Component

<aura:component>
    <lightning:select aura:id="selectItem" label="Select a Dashboard" onchange="{!c.navigateToDashboard}">
        <option value="">Choose a Dashboard ...</option>
        <option value="idofdashboard1">My Dashboard 1</option>
        <option value="idofdashboard2">My Dashboard 2</option>
    </lightning:select>
</aura:component>

JS Controller

navigateToDashboard : function(component, event, helper) {
    var dashboardId = component.find("selectItem").get("v.value");
    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({ "url": "/" + dashboardId});
    urlEvent.fire();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.