WDC Custom Initialization and Shutdown

Important: Tableau Web Data Connector 2.0 (this version) is being deprecated at Tableau 2023.1 and eventually retired. We will still support WDC 2.0 until its last compatible version of Tableau (Tableau 2022.4) goes End of Life and is no longer supported.

For information about Tableau Web Data Connector 3.0, see the WDC 3.0 documentation.


Your code might need to open a resource or perform a setup task for the data source. If so, you can run initialization code that is invoked at the beginning of each phase. If you don’t need custom initialization logic, you don’t need to do anything; code in the Tableau JavaScript library includes default initialization logic for you.

To implement custom initialization, you create an init function for your connector. In the function, run your initialization code. When initialization is complete, call the passed in initCallback to tell Tableau that initialization is finished, as in this example:

    myConnector.init = function(initCallback){
        // Your init code here
        initCallback();
    };

One typical scenario for using custom initialization code is to tell tableau about the auth needs of your connector. Please see WDC Authentication for details on this.

Similarly, if your connector needs to perform custom shutdown logic, you create a shutdown function for the connection. When the shutdown process is complete, call the passed in shutdownCallback, as in this example:

    myConnector.shutdown = function(shutdownCallback) {
        // Your shutdown code here
        shutdownCallback();
    }

As with initialization, if you don’t need custom shutdown logic, you can leave this out, because the code in the Tableau JavaScript library takes care of it for you.

The initialization or shutdown code is called once per phase. The code is called during the interaction phase and again during the gather data phase. If your initialization or shutdown code depends on which phase the connector is in, you can test the tableau.phase property. This property returns a string value that indicates the phase that the connector is in: tableau.phaseEnum.interactivePhase, tableau.phaseEnum.gatherDataPhase, or tableau.phaseEnum.authPhase. The following example shows how to use this property.

myConnector.init = function(initCallback) {
   initCallback();
   if(tableau.phase == tableau.phaseEnum.interactivePhase || tableau.phase == tableau.phaseEnum.authPhase) {
        tableau.submit();
    }
};

Running the connector without user interaction

If your connector doesn’t require user input, you don’t need to create a user interface for your connector. You just need to call tableau.submit when the connector has finished initializing. Include the following code to run a connector without user interaction:

myConnector.init = function(initCallback) {
    initCallback();
    tableau.submit();
};