31 August 2022 How to reuse script in Qlik Sense Share this message Every Friday at Bitmetric we’re posting a new Qlik certification practice question to our LinkedIn company page. Last Friday we asked the following Qlik Data Architect certification practice question about reusing script in Qlik Sense. The correct answer is C: On the server, store the script as a QVS file Given the fact that in bigger environments you will probably have to work with multiple developers or in bigger teams it is wise to have certain parts of the script readily available for reuse. By doing this, certain scripting logic and definitions are defined in a fixed place and thus possible to be reused everywhere. This is done by adding these parts of the script to a .QVS file and including them in the script by using include or must_include. Reusing script in Qlik Sense, an example Lets take the script below as an example. In here we define the various stages of publishing of the app based on a prefix given to the filename. For example [DEV] Sales Dashboard. This tells us that the Sales Dashboard is currently in the development phase. The script below defines based on this prefix that the variable vDTPFolder should be dev. This is used to determine the load location of the QVD files. It is not uncommon for development and testing data to be different datasets then the final production dataset. So in this case ‘[DEV] Sales Dashboard’ will load from: [lib://$(vDTPFolder)/Facts.QVD]. IF MATCH(LOWER(TEXTBETWEEN(DocumentTitle(),'[', ']', 1)), 'tst') THENLET vDTPFolder = 'tst';ELSEIFMATCH(LOWER(TEXTBETWEEN(DocumentTitle(),'[', ']', 1)), 'dev') THENLET vDTPFolder = 'dev';ELSELET vDTPFolder = 'prd';ENDIF; Since this DTP cycle will be used everywhere in the corporation’s environment, we want to use this script in every single application. Instead of answer A and mailing this script to all developers, it is a far better and more sustainable solution to store this on a server. This keeps maintainability to a minimum, since if changes occur, it is manageable from a single location. Also all newcomers can easily add this to their applications or understand what is happening. Storing Qlik script externally The script above needs to be stored before we can use it. This can be done by storing it as a .QVS file. QVS stands for QlikView Script and indeed comes from QlikView. In QlikView it was possible to export a whole script page at once to a QVS file. Under the file option you select ‘export to Export to Script file’ and this creates a QVS. While Qlik Sense is able to use QVS files, it is no longer possible to export them in the same manner. When using Qlik Sense you simply copy and paste the script you wish to reuse into a text file and store it. You can store this under .QVS or .TXT, since both will work. Including the script To include the script, we need to add it to the script in the data load editor. This is done by using include or must_include. The difference in both being, that must_include will give an error if the file cannot be found, while include fails silently. The syntax is as following: $(Include=filename) $(Must_Include=filename) So if we store the example above as DTPInclude.QVS and wish to have a notification when the file cannot be found, we use the following line in the script: $(Must_Include=lib://Scripts/DTPInclude.QVS); Please be aware that there may be no spaces between the equal sign, otherwise it will not work. When reloading Qlik will now run the stored script as it was there. That’s it for this week. See you next Friday? Take your Qlik skills to the next level! If you enjoy Qlik, you’ll love the Masters Summit for Qlik. 3 days of Qlik deep dives, peer networking, ready to use resources and much more! See you there! Test your Qlik knowledge! Check out the Friday Qlik Test Prep archive for more Qlik questions and answers. Friday Qlik Test Prep Script Solution How can we help? Feel free to contact us if you have any comments or questions. Call us Mail us 21 September 2023 Qlik Sense Enterprise for Windows – Critical Security Fix #2 A new security issue in Qlik Sense Enterprise for Windows has been identified. This resolves an incomplete fix for the vulnerability that was reported earlier this month. Patches are available and it is recommended to update your Qlik Sense Enterprise for Windows environment at the earliest possibility. New Release Qlik Security 6 September 2023 Battle Ships & Big Data: join us for some fun! Unleash the Power of Data in the Ultimate Battle Ship Game! Join us at the Big Data Expo for a thrilling experience that blends strategy, competition, and analytics. Discover how data influences gameplay and be part of our research! Plus, dive into the world of data and analytics with the experts from Bitmetric. Don’t miss out! See you at booth 46! Bitmetric Event Qlik Team 29 August 2023 Qlik Sense Enterprise for Windows – Critical Security Fixes Two security issues in Qlik Sense Enterprise for Windows have been identified and patches made available. Details can be found in Security Bulletin Critical Security fixes for Qlik Sense Enterprise for Windows (CVE-2023-41266, CVE-2023-41265). New Release Qlik Security
21 September 2023 Qlik Sense Enterprise for Windows – Critical Security Fix #2 A new security issue in Qlik Sense Enterprise for Windows has been identified. This resolves an incomplete fix for the vulnerability that was reported earlier this month. Patches are available and it is recommended to update your Qlik Sense Enterprise for Windows environment at the earliest possibility. New Release Qlik Security
6 September 2023 Battle Ships & Big Data: join us for some fun! Unleash the Power of Data in the Ultimate Battle Ship Game! Join us at the Big Data Expo for a thrilling experience that blends strategy, competition, and analytics. Discover how data influences gameplay and be part of our research! Plus, dive into the world of data and analytics with the experts from Bitmetric. Don’t miss out! See you at booth 46! Bitmetric Event Qlik Team
29 August 2023 Qlik Sense Enterprise for Windows – Critical Security Fixes Two security issues in Qlik Sense Enterprise for Windows have been identified and patches made available. Details can be found in Security Bulletin Critical Security fixes for Qlik Sense Enterprise for Windows (CVE-2023-41266, CVE-2023-41265). New Release Qlik Security