Automating Tableau Dashboard Delivery Using Tabcmd
Using tabcmd to automate Tableau dashboard distribution can be little tricky.
Add windows commands after your Tableau script later so you have an idea about how incorporate both of them into a single script.
The batch file must start with a login to the server. Tableau will always require a login to the server with a user account which has access to the dashboards we would like to distribute. Let’s break up that code:
The first command is the tabcmd command which tells windows this is a Tableau server command. We then define the server location which we are logging into by using “–s” or “–server”. We then use our login name preceded by “–u” or “–user”. Finally you’ll see that we have defined the password in the same manner, but instead of typing our password directly, we have referred tabcmd to a file location with our password typed into that file. The file must sit in the same location as the batch file which should reside in the “Command Line Utility” folder if you installed to the default location. The password file simply adds an additional layer of security to our batch file.
Now that we are logged into our server, we can start executing our commands.
Our command line will look like this:
The first command we execute is the “Get” command to Tableau server. Essentially we are telling Tableau server to go to the URL of the dashboard we want and “get” a PDF copy of that dashboard. It will automatically get it, and download it to the “Command Line Utility” folder on the local machine.
You may also notice that I have added a ?RegionParameter=West designation to our URL . This designation allows me to leverage a parameter in my dashboard named “RegionParameter”. Adding it to the URL allows me to filter each get command differently so each downloaded PDF will be specifically relevant to the users for which they are intended. For example the first URL above will create a view for my Western regional manager, but I just need to add a second line and change the filter to South I will have one PDF for my Southern manager and one for my Western manager. I have also added a command to give my PDF a specific filename (we’ll see why later) and a timeout counter in case my server becomes unresponsive.
I’ll then logout of tabcmd by adding the command “tabcmd logout” at the end of my script. That is all of the Tableau command lines I need to write. Just remember to save the file with a .bat extension. The PDFs are downloaded onto my local machine and I can send them out manually via email to each user.
However if I wanted to take the automation a step further I could add a few more lines in the same batch file to move them to a networked location or a mapped drive. This next section of code does that for me. In this specific case tabcmd was installed to c:tabcmd instead of the “command line utility” folder.
I just added a “move” command which tells Windows to move the files from one location to the location which follows. Since I wanted old files to be overwritten by the new ones I chose the “/Y” switch with tells Windows to overwrite the old files for me.
Comments
Post a Comment