Embedding Einstein Analytics Dashboard in Salesforce Platform

Embedding dashboards, record hierarchies, Einstein actions, filter syntax, Lightening Pages and Visualforce Pages

Embedding Einstein Analytics Dashboards on Salesforce platform record pages offers insights at record levels. This approach lets users leverage the power of Einstein Analytics on the Salesforce Platform directly. For example, building a dashboard in Einstein Analytics with account object as the grain provides users with an aggregated view of multiple Accounts (based on user access to records). However, for record level account analysis to be straightforward, we must manually filter to a specific account on the dashboard.

By embedding this Dashboard on the Account Record page in Salesforce, the account details are instantly filtered, offering rich and dynamic detail. Every visualization on the dashboard is filtered to that specific account record by default, so users don’t have to make manual selections in any filters on the dashboard to access individual account information.

An ideal use case for embedding dashboards is a scenario where users would want to readily monitor the health of an account in Salesforce record pages. Let’s say John Edward, the manager of a Quality team at an Oil and Gas firm, wants a way to continuously monitor the quality and health of individual Suppliers, for example, how many quality cases have been registered for each supplier and how many of them are an active or high priority. The first step is to create Einstein Analytics Dashboards with ‘Account/Supplier data and Quality Cases’ datasets with these visualizations. The next step is to embed this dashboard on the Supplier Record page. Now, if John opens the record page of a specific supplier, the Einstein Dashboard on the record page of the supplier will display the most efficient way of monitoring the supplier performance. Using these powerful Einstein visualizations embedded on Salesforce record pages greatly enhances the user experience on the platform itself.

To take this a step further, users can deploy embedded dashboards with Einstein actions. Enabling actions such as Assigning Tasks, logging a call, posting to Chatter, and Creating Events, allows for seamless visibility in taking action on insights. When assigning follow-up actions to a Sales Rep on underperforming Accounts, Einstein Actions speeds up the process of identifying issues and taking action, helping businesses to take action faster.

The use cases can even extend to monitor the Financial Health, such as a number of invoices, total expenditure and how much of it is capital or operational expenditure. Questions such as ‘Which accounts are more costly for a business and yielding less ROI compared to expenditure?’, can be effectively answered with embedding dashboards in the platform.

We can also configure the dashboards for hierarchies. For example, say a parent supplier has 4 child suppliers under the supplier hierarchy. When a user opens the Record page, they are able to specifically select the parent supplier and see the aggregated roll up numbers from that supplier as well as the underlying 4 child suppliers. This can be achieved by using the flattening hierarchy field in dashboard filters and flattening the Parent ID onto all the child records to derive the desired roll up results.

Note: Enabling this embedded functionality on Salesforce mobile app offers the ideal scenario for higher user adoption. It involves embedding on Visualforce pages because embedded dashboards on Lightening pages can’t be seen in the Salesforce mobile app.
 

Desktop Experience: Embedding Dashboards on Lightning Pages

For desktop experience, Einstein Analytics dashboards can be embedded on Lightning pages of Salesforce objects. For more information on how to embed a dashboard on Lightning,please refer to this link. A simplified explanation of Lightning filter syntax can be seen below:

The whole idea is to match the field on the dataset, used in the dashboard, with a Record field on the Salesforce Object. Below, syntax shows embedded dashboard filtered on two datasets. In the syntax, Field1 and Field2 are the dataset fields and Dataset1 and Dataset2 are the corresponding two datasets used on the dashboard. $FieldS can be any field on the record page that uniquely identifies the record, for example: ‘Record Id’ i.e., $Id
 

Multi Dataset Filter Syntax for Lightning Embedding Dashboards:

 

{
  "datasets": {
    "Dataset1": [
      {
        "fields": [
          "Field1"
        ],
        "filter": {
          "operator": "matches",
          "values": [
            "$FieldS"
          ]
        }
      }
    ],
    "Dataset2": [
      {
        "fields": [
          "Field2"
        ],
        "filter": {
          "operator": "matches",
          "values": [
            "$FieldS"
          ]
        }
      }
    ]
  }
}

JSON Chrome editor for editing the Filter syntax (shown above) for Embedding Dashboards.

The above syntax is simplified for explanation. Remove the formatting and spaces when actually putting it on the Lightning page (see below). Also, “Field name” should be the API Name of the field.
 

{'datasets':{'Dataset1':[{'fields':['Field1'], 'filter':{'operator': 'matches', 'values':['$FieldS']}}],'Dataset2':[{'fields':['Field2'], 'filter':{'operator': 'matches', 'values':['$FieldS']}}]}}
 

Mobile Experience: Embedding Dashboards on VisualForce Pages

Currently, Wave components on Lightning pages are not supported for the Salesforce Mobile App. Therefore, in order to show the embedded dashboards on the mobile app, we need to embed the dashboards on Visualforce pages. Then, these Visualforce pages can be set up on Object Page Layouts.

Note: Lightening Pages are set up on ‘Lightening Pages’ of the Object, whereas Visualforce pages are set up on Page Layouts of the Object.
 

Creating Visualforce Page with Einstein Analytics Dashboard

In order to create a Visualforce page, navigate to Setup, search for “Visualforce page” and click on “New”. For more info on documentation see this link, Navigation:  Setup → (Search) Visualforce Pages → New

For simplified information on Apex code and filter syntax for Visualforce pages see below.
 

Multi Dataset Syntax: Embedded Dashboard for Visualforce Page:

 

<apex:page sidebar="true" standardController="ObjectAPIName" >
        
  <wave:dashboard dashboardId="DashboardId"
        height="1200px"
          showTitle="false"
          showHeader="false"
          showSharing="false"
          openLinksInNewWindow="false"
          hideOnError="true"
          
          filter="{'datasets':{'Dataset1':[{'fields':['Field1'], 'filter':{'operator': 'matches', 'values':['{!ObjectAPIName.FieldS}']}}],
          'Dataset2':[{'fields':['Field2'], 'filter':{'operator': 'matches', 'values':['{!ObjectAPIName.FieldS}']}}]}}]}}" >
 
</wave:dashboard>
   
</apex:page>

 
Apex code shown above identifies the Object Record Page with ObjectAPIName.FieldS (ex: ObjectAPIName is the API Name of the Object, like ‘Opportunity’ and Field$ is the API name of the field on the corresponding Object (‘Id’), therefore it would be something like “Opportunity.Id”, ObjectAPIName is also used for standardController (this assigns Visualforce page on that particular Object). Similarly Dataset1, Dataset2 are the Dataset names from Einstein Analytics and Field1 and Field2 are the field names on those respective Datasets, DashboardID is the 18 digit ID of the Dashboard (see URL of the Dashboard).

Since we are using standardController, users don’t need the Test class that is normally needed for customController, which is used when dealing with cross-object referencing.

Note: When you click preview on the Visualforce page (Embedded Dashboard with Filters), don’t be alarmed by seeing widgets throwing errors. In Preview mode, Filter syntax renders the Dashboard errors as it doesn’t know the filtered Fields unless the dashboard is viewed on a record page.

From page layouts, click the Visualforce pages in the selection palette. Once you find the list of Visualforce pages that you have access to, just drag and drop it in the Mobile cards (Salesforce mobile only) section.


 

Access to Visualforce Pages:

Finally, users need to have access to the Visualforce pages in order to view the Dashboards in Mobile app. When Security is clicked, a page is opened with a list of profiles. Simply transfer the needed Profile from ‘Available Profiles’ to ‘Enabled Profiles’. (See image below).

Note: In the Salesforce Mobile App, navigate to the Record Page. Through the Visualforce page, you will find the Mobile Embedded dashboard on the ‘Related’ tab.