include and must_include

The include and must_include variables are used to call a file which contains text that must be executed as code as part of the script. These are usually QVS (QlikView script files) or the famous TXT files.

This is very useful for when we want to reuse code created in other applications. It is a great way of sharing and reusing code.

Also, exporting script code into files is a great way to version control the scripting logic and to track changes.

The following is the syntax for these variables:

$(include=filename);
$(must_include=filename);
A blank space right after the equal sign in the include or must_include variables will throw an error. 

The difference between these two variables is that include does not throw an error if the file specified in filename is not found. On the other hand, must_include will generate an error if the files do not exist in the specified location.

I strongly recommend you use must_include to improve debugging.

Even though I would encourage the use of must_include, I would personally use include when importing files generated by users or the business. These files are usually add-ons and are non-essential to our data model. If the file gets mistakenly deleted by the user, it would prevent our scripts from running properly. 

On the other hand, files or scripts that are critical to our data model, such as an external file containing Section Access script, must always be loaded using must_include, otherwise there is a risk that someone could delete the file and thus the application would load without any section access in it, allowing access to anyone with a token.

As opposed to other structures in the script, these two variables allow the file name to be specified as part of an absolute file path. For example:

$(must_include=C:MyDocumentsIncludeFile.txt);

However, it can also be called from a folder connection:

$(must_include=lib://myFilesIncludeFile.txt);

Even though they are both acceptable, in Qlik Sense, I recommend you use the latter through the use of folder connections.

Remember, the contents of the files that are included using Include and Must_Include are executed as code, so make sure they comply with Qlik Sense script syntax.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.183.153