NULL errors have cropped up twice in recent development projects utilizing Tableau’s JavaScript API. In one instance, getWorkbook() returned this error:
SCRIPT5007: Unable to get value of the property 'get__workbook': object is null or undefined
In another instance, getActiveSheet() returned this error:
Uncaught Error: Internal error. Please contact Tableau support with the following information: Unknown sheetType ‘undefined’
Both times, the errors seemingly appeared all of a sudden and for no obvious reason. What changed?
Tableau has been hard at work, updating and upgrading the JavaScript API that they provide. Developers use this API to embed Tableau visualizations/graphs into a variety of web applications and frameworks. Recently, I’ve ran across two instances where Tableau’s updates have had the unfortunate side-effect of breaking a client’s site.
Case #1: Using an Older Tableau Workbook with a Newer Version of the API Script
The first time I ran across this problem, my client was on the cusp of releasing a new version of their website. The project team consisted of several developers, and we had been furiously testing our code from all angles to prepare for the launch. Seemingly overnight, everything that depended on Tableau’s API script stopped working. No matter how much of our custom code we stripped out, the same error was occurring. Every time, the error was generated when we tried to use the ‘getActiveSheet()’ function:
Uncaught Error: Internal error. Please contact Tableau support with the following information: Unknown sheetType ‘undefined’
We finally swallowed our pride and opened a support ticket with Tableau. After they had a chance to review our code, they responded with the following:
The reason that the application is not working is that the JavaScript API being used is actually the API for Tableau Public, which was upgraded to 8.2 recently. Tableau Online is still 8.1, so that is the API that should be used so the versions match.
Changing this—
—to this—
—should resolve the issue.
As soon as we updated the script reference, everything started working again.
Case #2: Using a Newer Tableau Workbook with an Older Version of the API Script
Another client reported a problem recently that involved a completely different error message, but the circumstances were incredibly familiar. Seemingly overnight, all JavaScript that depended on the Tableau API script stopped working. In this instance, it appeared to be the ‘getWorkbook()’ function, which was returning the following error:
SCRIPT5007: Unable to get value of the property 'get__workbook': object is null or undefined tableau-api.js, line 2796 character 9
Most clients that use Tableau’s API script reference it directly from Tableau’s servers. But in this instance, the client had downloaded the script to their server in order to prevent security errors inside their corporate firewall. I suggested grabbing the latest version of the script file from Tableau, and the problem resolved itself immediately.
Conclusion: Don’t Beat Yourself Up
Things are always in flux. It’s the nature of web development. In both instances above, developers spent countless hours trying to debug their custom code. In the end, it was simply a version mismatch between the Tableau workbook and the Tableau JavaScript API. If you’re a developer using this API, and everything suddenly seems to break, my advice is to start by scrutinizing the version of Tableau’s script that you’re using.