Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface DataSource

Represents the data source used by a Worksheet.

Hierarchy

  • DataSource

Index

Properties

extractUpdateTime

extractUpdateTime: string | undefined
returns

Last update time of the data source's extract, or undefined if this data source is live.

fields

fields: Array<Field>
returns

An array of fields associated with this data source.

id

id: string
returns

Unique string representing this data source.

isExtract

isExtract: boolean
returns

True if this data source is an extract, false otherwise.

isPublished

isPublished: boolean | undefined
returns

True if this data source is published to server, false otherwise. Always undefined prior to Tableau 2021.4.

since

1.7.0 and Tableau 2021.4

name

name: string
returns

The user friendly name of the data source as seen in the UI.

Methods

getActiveTablesAsync

  • throws

    UnsupportedMethodForDataSourceType error if this method is called on a Cube DataSource or GA.

    deprecated

    since version 1.4.0. Use DataSource.getLogicalTablesAsync.

    Returns Promise<Array<TableSummary>>

    An array of table summary objects that are currently used in the data source.

getConnectionSummariesAsync

  • Returns Promise<Array<ConnectionSummary>>

    An array of descriptions of the connections within this data source.

getLogicalTableDataAsync

  • Gets the underlying data table for the given logical table id.

    since

    1.4.0

    since

    1.5.0 Use the DataSourceUnderlyingDataOptions.includeDataValuesOption option to optimize performance by restricting the properties included in the returned DataValues.

    since

    1.5.0 Columns to include can be specified by id using the DataSourceUnderlyingDataOptions.columnsToIncludeById option.

    Parameters

    Returns Promise<DataTable>

    A data table containing the underlying data of the data source.

    The following example shows use of the getLogicalTableDataAsync() method to get the data from a specific logical table in a data source. The example uses the JavaScript find() method to select the workbook, and uses the getLogicalTablesAsync method to identify the logical table id.

    tableau.extensions.dashboardContent.dashboard.worksheets.find(w => w.name === "Sale Map").getDataSourcesAsync().then(datasources => {
      dataSource = datasources.find(datasource => datasource.name === "Sample - Superstore");
      return dataSource.getLogicalTablesAsync().then((logicalTables) => {
       return dataSource.getLogicalTableDataAsync(logicalTables[0].id)
      });
     }).then(dataTable => {
        console.log(dataTable);
        let field = dataTable.columns.find(column => column.fieldName === "Sub-Category");
        let list = [];
        for (let row of dataTable.data) {
            list.push(row[field.index].value);
        }
        let values = list.filter((el, i, arr) => arr.indexOf(el) === i);
        console.log(values)
    });
    

getLogicalTablesAsync

  • Gets the underlying logical tables used in the data source.

    since

    1.4.0

    Returns Promise<Array<LogicalTable>>

    An array of logical tables that are currently used in the data source.

    The following example uses the getLogicalTablesAsync method to print the names of the the logical tables to the console.

    dataSource.getLogicalTablesAsync().then(function (logicalTables) {
      // Loop through each table that was used in creating this data source
      logicalTables.forEach(function (table) {
         console.log(table.caption);
      });
    });

getUnderlyingDataAsync

  • deprecated

    since version 1.4.0. Use DataSource.getLogicalTableDataAsync.

    Parameters

    Returns Promise<DataTable>

    Returns a promise containing a page of data from the underlying data of the data source.

    The following example shows use of the getUnderlyingDataAsync() method to get the underlying data from a specific data source. The example uses the JavaScript find() method to select the workbook and data source.

    tableau.extensions.dashboardContent.dashboard.worksheets.find(w => w.name === "Sale Map").getDataSourcesAsync().then(datasources =>
    {dataSource = datasources.find(datasource => datasource.name === "Sample - Superstore");
      return dataSource.getUnderlyingDataAsync();
     }).then(dataTable => {
        let field = dataTable.columns.find(column => column.fieldName === "Sub-Category");
        let list = [];
        for (let row of dataTable.data) {
            list.push(row[field.index].value);
        }
        let values = list.filter((el, i, arr) => arr.indexOf(el) === i);
        console.log(values)
    });
    

refreshAsync

  • refreshAsync(): Promise<void>
  • This call has the same functionality as clicking the Refresh option on a data source in Tableau. This does not refresh an extract.

    Note: The refreshAsync() method is intended to be used in scenarios where manual interaction causes a need to refresh the data in the Tableau visualization. The method is not, as currently designed, meant to support or emulate streaming or live visualizations. Extensions that use the method to refresh aggressively or automatically can cause issues on Tableau Server and Tableau Online and are subject to being blocked by the Tableau Online administrator.

    This call does not currently support refreshing live Google Sheet data sources.

    Returns Promise<void>

    Promise that resolves when the data source has finished refreshing.