Tutorial Tuesday: Implementing version control for Qlik Sense with Git, GitHub and Visual Studio Code

By Vincent Hayward

Welcome to my second Blog post, which will be a basic tutorial of how to setup a lightweight version control for Qlik Sense script. This approach is straight forward to implement in various occasions. My aim is not to over complicate version control by offering this as a nice beginners guide on version control and workflow.

This tutorial will be part of a series of Tutorial Tuesdays that will lead to a lightweight, straight forward and easy to implement framework within Qlik Sense. In the series of tutorials hereafter will we cover topics as version control with script changes, different localization settings, loading centralized variables, creating master items on variables and eventually getting a simple dashboard up and running based on all tutorials altogether.

This tutorial is divided into 4 parts, in part 1 we will set up a remote environment for Git repositories at GitHub, in part 2 we will install local software, in part 3 we will building your project and part 4 is committing changes and synchronizing with the remote repository at Visual Studio Code.

Why use version control?

With version control you keep track of any changes to the code. If an error is made, you can roll back to a previous version of the code and you can compare previous versions of the code to correct the error and minimize disruption for other developers. Version control protects source code from catastrophes, human errors and / or unintended consequences of changes.

Before we start we need to download a bit of software, like Git and Visual Studio Code, the installation of which will be covered in part 2. As well as creating an account at GitHub, the configuration of which will be covered in part 1.

Part 1 – Setting up a remote environment for Git repositories at GitHub

Login at Github

First we are going to set up the GitHub by creating an account and then sign in. After you have signed in; you can create a new repository by clicking on the “New” button on the left part of the screen.

Create a new repository at Github

At the new page with the title “Create a new repository” you can fill in the details, as repository name, description and set the repository on public / private and then click Create repository.

Filling in the repository details

After creating the repository successfully you will end up at the repository page of the created repository bitmetric_random_sales_model, where we can copy the HTTPS link for further use.

Repository tab code

Now the remote repository has been set up at GitHub, we can continue with the installation of Git.

Part 2 – Installation of local software

If you haven’t downloaded Git yet, you can download it at
Git. The installation of Git is pretty straight forward, which means pretty much clicking the [Next] button up to the moment Git has been successfully installed. So keep all the settings as default selected during the installation process.

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency and Git is by far the most widely used modern version control system in the world today.

After you successfully installed Git as the SCM, it’s time to install the code editor Visual Studio Code. The installation of Visual Studio Code is pretty straight forward as well. After you successfully installed Visual Studio Code, you may open the application.

Welcome screen of Visual Studio Code

The first screen you see when opening Visual Studio Code is the Welcome screen, which can be closed. At this point we haven’t connected Visual Studio Code with a source control provider yet. So the next step is installing the extension Git History. Click Shift + Ctrl + X to go the Extension Marketplace and search for the extension Git History and install it.

Install extension Git History

So now we have installed everything we need in order to set up a workspace folder by cloning the online repository at GitHub, we have setup at Part 1. Open the Command Palette (Ctrl + Shift + P) and type in Git, as you can see different commands started with Git appear. Choose Git: Clone.

Clone GIT repository

After you started the command Git: Clone you need to enter the repository url from Part 1 at GitHub and in my example that would the URL https://github.com/vmfhayward/bitmetric_random_sales_model.git

After you entered the repository URL, you will need to select the workspace folder. In this case we are going to E:\Qlik Sense Repositories and press the button [Select Repository Location]. Now the repository at GitHub has been connected to E:\Qlik Sense Repositories\bitmetric_random_sales_model

Select the target folder for the GIT Repository to clone to

Now when successfully followed the steps above we get a message at the bottom right of the screen “Would you like to open the cloned repository?”. Now click on Open Repository and you will automatically return to the Explorer menu, where the folder bitmetric_random_sales_model has been added. But is yet empty!

So let’s create our very first file at the workspace folder. To do so click on the new file icon next to bitmetric_random_sales_model and name the file
named Bitmetric Random Sales Model.qvs

(Animated GIF) Creating a new file Bitmetric Random Sales Model.qvs

Now that you have created an empty file Bitmetric Random Sales Model.qvs, we can go to Qlik Sense and create an application.

Part 3 – Building your project

The next thing we can do is creating an Qlik Sense application and move the localization settings that is generated automatically from the Qlik Sense application to the script we created in part 3. In our example we created an application in Qlik Sense Desktop called Bitmetric Random Sales Model.

Open the Qlik Sense application and select and cut the script and then paste this script in the Bitmetric Random Sales Model.qvs at Visual Code Studio. Now switch back to the Qlik Sense application and add the following line:

$(MUST_INCLUDE=[lib://Bitmetric Random Sales Model/
Bitmetric Random Sales Model.qvs ]);

(Animated GIF) Get script from Qlik Sense application and replace it with an include to the script file
(Animated GIF)Adding script tot the script file Bitmetric Random Sales Model.qvs

Now we are almost done!

So at this point we have created a script file with lines of Qlik code, both localization settings as well as a data model script by remote include and we have added the script file Bitmetric Random Sales Model.qvs to our Qlik Sense application with an include line.

Script file Bitmetric Random Sales Model.qvs
Include of Bitmetric Random Sales Model.qvs in Qlik Sense application

At this point we can of course load the application successfully and get some data to work with. But we still need to push the local script file Bitmetric Random Sales Model.qvs to our remote repository at GitHub.

Part 4 – Commit changes and synchronize with the remote repository at Visual Studio Code

So first we need to commit the changes of the file at Visual Studio Code with Source Control (Ctrl + Shift + G), then at Changes you see the file Bitmetric Random Sales Model.qvs. Click on the + icon to stage the changes of this file. Add some text i.e. description what you have changed or a ticket / request number, where you see “Message (Press Ctrl+Enter to commit)” and then commit the changes by clicking the V-icon.

(Animated GIF)Commit changes of the script file Bitmetric Random Sales Model.qvs

After you have committed the changes, you can synchronize it with the remote repository at GitHub by clicking synchronization-icon (circle with the 2 arrows) bottom left of Visual Studio Code. After you have synchronized is successfully you can check the results at your GitHub account.

(Animated GIF) Synchronize your workspace folder with your GitHub repository

If everything went well you will end up with the script file in your remote repository at GitHub. Every time you do changes in your script, just commit them within Visual Studio Code and synchronize them to GitHub. This way you can access your script whenever and wherever.

The GitHub Repository is synchronized succesfully

Now you are all set!

Bonus

With Visual Studio Code the following extensions could become very handy to add to your developer toolkit: Excel Viewer, Qlik and vscode-icons. But remember to reload Visual Studio Code after installing extensions to activate them properly.

A good video about changing script and committing changes can be found at https://scotch.io/tutorials/git-integration-in-visual-studio-code

About The Author

Vincent Hayward

Vincent knows from an early age what he wants to do; something with computers. Thinking of Business Intelligence solutions is his passion and especially with QlikView and Qlik Sense. In addition to being an enthusiastic Business Intelligence Consultant; Vincent is father of 2 children and is married. In his spare time, Vincent is a indoor soccer player, videogamer and politician in the municipality of Westland.

8 Comments

  • 1
    Steve Newman
    March 12, 2019 - 14:46 | Permalink

    Awesome tutorial Vincent.

    I have been using this technique for quite some time and appreciate your documentation/tutorial to get more people using it.

    I use ATOM as my text/github editor, instead of Visual Studio Code and it also has a Qlik plugin for syntax highlighting called: language-qlik-view. Good to share other approaches. Thanks!

    • 2
      March 12, 2019 - 19:20 | Permalink

      Yes, ATOM is a perfect editor as well. I think Nick Webster is using that one, so it must be good. For me I started with ATOM (https://atom.io) but then at one of our customers, it was default to use Visual Studio Code and then you get used to it and well … it became my default as well.

  • 3
    Jonas
    March 19, 2019 - 23:52 | Permalink

    Yes. But strangely, you seem to forget 50% of the solution: The GUI.

    How about governing changes in an app GUI together with the app data model (script)?

  • 4
    March 20, 2019 - 12:02 | Permalink

    This post is meant as an introduction / primer, things will become more sophisticated as this series progresses.

  • 5
    Melinda Bruck
    March 21, 2019 - 14:37 | Permalink

    Great info! I can’t wait to see the series progress.

  • 6
    Ayo
    March 27, 2019 - 10:25 | Permalink

    Great post Vincent, I am strongly looking forward to the GUI part that Jonas mentioned – .”How about governing changes in an app GUI together with the app data model (script)”

    Thanks again.

  • 7
    April 9, 2019 - 15:46 | Permalink

    I would consider looking into the old Backup/Restore mashup, now bundled with the Qlik Sense QMC Utilities: https://github.com/eapowertools/QlikSenseQMCUtility

    You could use the same general approach as outlined above, but instead of the .QVS, you would generate and commit a JSON file that contains the script *and* UI contents.

  • 8
    Matt Nunn
    April 27, 2019 - 09:16 | Permalink

    Thanks Vincent. This is an excellent post.

    If want to automatically synchronize the repository after each commit you can do this:

    1. Go to the VS Code Settings menu (Gear on the bottom left > Settings)
    2. Search for git.postCommitCommand
    3. Select the sync option

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    Read previous post:
    Qlik named a leader again in the 2019 Magic Quadrant

    Qlik has been named a Leader in the 2019 Magic Quadrant for Business Intelligence and Analytics Platforms for the 9th...

    Close