Giter VIP home page Giter VIP logo

tableau-viz-lwc's Introduction

Lightning Web Component for embedding Tableau into Salesforce

GitHub Workflow GitHub version - Release Notes (v1.2)

This project provides a Lightning web component that you can customize, deploy, and use to embed a Tableau visualization into Salesforce. This component uses the Tableau JavaScript API for embedding Tableau views into web pages.

Trailhead Badge Learn more about the Tableau Viz Lightning web component by completing the Embed Tableau Visualizations in Salesforce Trailhead project.



This sample component is designed to run on the Salesforce Lightning Platform.

Table of contents


For a demonstration of the Tableau Lightning web component in action, see the Tableau Viz Lightning web component video.

Install the Tableau Viz Lightning web component from the AppExchange

The easiest way to install the Lightning web component for Tableau is from the AppExchange.

The Tableau Viz web component on AppExchange is a container for the Tableau Visualization component available in this GitHub repository. You can install the component in production environments, or in sandbox or Developer Edition organizations on Salesforce, or in test organizations furnished through the Environment Hub. You can learn more about the Tableau Viz Lightning web component, see Embed Tableau views in Salesforce.

After you install the package, you can Add the Tableau Visualization component to a Lightning page.


Install the component using a Scratch Org

  1. Set up your environment. Follow the steps in the Quick Start: Lightning Web Components Trailhead project. The steps include:

    • Enable Dev Hub in your Trailhead Playground (Important)
    • Install Salesforce CLI
    • Install Visual Studio Code
    • Install the Visual Studio Code Salesforce extensions, including the Lightning Web Components extension

    Tip: You do not need to complete the last module and create the Hello World Lightning Web Component. We use the Trail here just to help you set up your environment.

    Note: You will use the Salesforce CLI to perform the following steps. Be sure you enable Dev Hub in your Trailhead Playground before you begin. Login to your Playground. Go to Setup > Development > Dev Hub).

  2. If you haven't already done so, open a Command or Terminal window and authorize your hub org and provide it with an alias (myhuborg in the following command):

    sfdx force:auth:web:login -d -a myhuborg
    
    
  3. Clone the tableau-viz-lwc repository:

    git clone https://github.com/tableau/tableau-viz-lwc
    
    
  4. Navigate to the directory of the repository you just cloned.

    cd tableau-viz-lwc
    
    
  1. Create a scratch org and provide it with an alias (tableau-viz-lwc in the command below):

    sfdx force:org:create -s -f config/project-scratch-def.json -a tableau-viz-lwc
    
    
  1. Push the component to your scratch org:

    sfdx force:source:push
    
  2. Open the scratch org:

    sfdx force:org:open
    
    

    This opens Salesforce and takes you to the scratch org.

  3. Now you can Add the Tableau Visualization component to an Lightning page.


Install the component using a Developer Edition Org or a Sandbox

Follow this set of instructions if you want to deploy the component to a more permanent development environment than a Scratch org. This includes non source-tracked orgs such as a free Developer Edition Org or sandboxes.

  1. Authorize your org and provide it with an alias (mydevorg in the following command):

    sfdx force:auth:web:login -s -a mydevorg
    
  2. Clone this repository:

    git clone https://github.com/tableau/tableau-viz-lwc
    
    
  3. Navigate to the directory of the repository you just cloned.

    cd tableau-viz-lwc
    
    
  4. If you are setting up a Developer Edition: go to Setup, under My Domain, register a My Domain.

  5. Run this command in a terminal to deploy the component.

    sfdx force:source:deploy -p force-app
    

    If see an error message that asks you to specify a username or OAuth options, use the following command and replace username with the login name you use for mydevorg.

    sfdx force:source:deploy -p force-app -u username
    
  6. If your org isn't already open, open it now:

    sfdx force:org:open -u mydevorg
    

    This opens Salesforce and takes you to your Developer Edition Org.

  7. Now you can Add the Tableau Visualization component to a Lightning page.


Add the Tableau Visualization component to a Lightning page

After you have successfully deployed or pushed the tableau-viz-lwc component to your Salesforce org, you can use the component to add a Tableau viz to a Lightning page.

  1. From the App Launcher (App Launcher), find and select Sales (or any other App that provides a page where you can embed the Tableau Lightning Web Component).

  2. Click the Setup gear (Setup gear) then select Edit Page.

  3. Drag the Tableau Visualization component from the Custom area of the Lightning Components list to the top of the Page Canvas.

  4. Select a Tableau viz to display by providing the URL for the viz in the The URL for the Tableau view text box.

    To find the URL for a viz on Tableau Server or Tableau Online, click Share on the toolbar and select Copy Link from the Share View dialog box. For Tableau Public, copy the URL for the viz from the address bar in your browser.

    In Salesforce, use the options for the Tableau Visualization component to control the size of the viz and whether you want to show the Tableau toolbar or any tabs for the viz.

For this first release, we support SSO only with SAML. If you want to configure Tableau to use Salesforce IdP, follow the steps described in Configure SAML with Salesforce and Configure SAML for Tableau Viz Lightning Web Component for Tableau Online. For Tableau Server, see Configure SAML for Tableau Viz Lightning Web Component for Windows and Configure SAML for Tableau Viz Lightning Web Component for Linux.

Tableau Visualization LWC


Try filtering

The Tableau Lightning web component supports two ways of filtering the Tableau visualization. These methods of filtering only work on Lightning record pages. Filtering is not available for Home pages or App pages. For record pages, you can automatically filter the Tableau visualization based upon the page it is embedded in (context filtering), or you can specify fields in Tableau and in Salesforce to create more sophisticated filtering.

Context filtering

To have the visualization filtered based upon the page it is embedded in, the Tableau viz needs to have a field that corresponds to the record page ID. For example, if you want to embed a viz for sales on a user's page that shows just the sales for that user, the Tableau viz should include a field that holds the record IDs for users.

  1. In your Salesforce org, select a record page where you want to embed the viz (for example, Users or Opportunities).

  2. Edit the record page and configure the component by entering the URL of the Tableau viz that contains the data you want to display. The Tableau visualization must include that a field that holds the record IDs (for example, user or account IDs).

  3. Select Filter the Tableau view based upon the current Salesforce record and save your changes to the page.

    When the record ID of the page matches the corresponding value in a field in the Tableau viz, the component applies that filter. For example, component filters the viz to show just the sales data for the user on the user's page.

Advanced filtering

If you want more control over filtering the Tableau visualization on a records page, you can map a field in Tableau to a specific field in Salesforce.
The Tableau field needs to be on the viz that you are embedding. The Salesforce field must be a qualified field on the page where you are embedding the viz. When the values of these two fields match, the Tableau Lightning web component will automatically filter the Tableau viz.

To test out this filtering, you can add the Tableau Visualization component to a record page. For example, if you have a Tableau viz that contains data that is related to sales information, you can add that viz to your opportunity record pages.

  1. In your Salesforce org, click the App Launcher (App Launcher), find and select Sales, then click the Accounts tab. Select an account, for example, Burlington Textiles from the All Accounts list.

  2. Click the Setup gear (Setup gear) then select Edit Page.

  3. Drag the Tableau Visualization component from the Custom area of the Lightning Components list to the top of the Page Canvas.

  4. Configure the component.

    • Enter the URL of the Tableau viz that contains the sales data you want to display.

    • Provide the name of the the Tableau field to use for filtering. The Tableau field needs to be the name of a field in the viz that you are embedding. For example, the viz might contain a field for the User ID.

    • Provide the name of the the Salesforce field to use in filtering. You can select the qualified field names for the page from the drop-down list. For example, on the account record page, you could select Owner ID.

    When the values from these two fields match, the LWC will automatically filter the Tableau viz.

    Tableau Visualization LWC Filter Settings

  5. Save your changes to the page.


Sign up for the Tableau Developer Program

We want to hear from you!

Flex DataDev Warrior

Join the Developer Program and gain access to the latest news about the Tableau developer platform and tools.

  1. To join the Developer Program, go to (https://www.tableau.com/developer) and use your Tableau login to sign up. After you join, you can sign up and get a Tableau Online developer site (https://www.tableau.com/developer/get-site). With this free developer site, you can try the single sign-on experience using Salesforce as your SAML IdP and configuring SAML on Tableau Online, or you can just use the site to embed a viz from Tableau Online.

  2. Try out the Tableau Viz Lightning component and samples!

Welcome to the #DataDev Community!


Troubleshooting problems deploying the Tableau Lightning web component

  • Tip: Be sure to run the sfdx commands from within the project folder.

  • If you encounter the following error message when trying to create a scratch org:

    ERROR running force:org:create: You do not have access to the [ScratchOrgInfo] object

    If you have not already done so, you might need to enable Dev Hub in your org. Login to your org and go to Setup > Development > Dev Hub). Or search for "Dev Hub" in the Quick Find text box.

  • If you encounter the following message when trying to deploy the component:

    ERROR running force:source:deploy: Must pass a username and/or OAuth options when creating an AuthInfo instance.

    Use the -u username option. To determine the username for your Salesforce org, you can use the command sfdx force:org:list to display information about the orgs you have created or are connected to.

For more information about fixing problems with deployment, see Troubleshoot Salesforce DX in the Salesforce DX Developer Guide.

Release Notes

Version 1.2

October 17, 2020

Using the Tableau Viz Lightning web component on Lighting communities

Salesforce Spring '21 is removing the Allow Inline Scripts and Script Access to Any Third-party Host Content Security Policy (CSP) setting for Lightning communities. For Winter `21, Salesforce recommends switching your community to a more secure option now.

To support the increased level of security, version 1.2 of the Tableau Viz Lightning web component adds Tableau Public and Tableau Online as trusted web sites in the managed package. If you are using the Tableau Viz Lighting web component on Lighting community pages and want to embed Tableau views from Tableau Public and Tableau Online, the version 1.2 package handles the CSP change for you. However, if you want to add views from Tableau Server, you need to add the Tableau Server URL as a CSP Trusted Site. For information about how to add Tableau Server as a trusted site, see the Salesforce Help documentation, Create CSP Trusted Sites to Access Third-Party APIs.

Fixed in this release

  • [Fixed] When you opened a Salesforce page for editing that contains a Tableau view from Tableau Online on the page, the tabs and the toolbar are shown even if the Show Toolbar and Show Tabs options were not selected.

Version 1.1

September 21, 2020

  • Initial public release of the Tableau Viz Lighting web component.

tableau-viz-lwc's People

Contributors

illonage avatar d45 avatar pozil avatar lgraber avatar johnnyyan avatar johnnyattableau avatar benlower avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.