Following this post which talks about methods for configuring apps, this post looks at how to achieve this via the QMC in QlikView and set variables in reloaded QVWs.
You’ll need to have Publisher enabled to access the features used for this example.
In a QlikView deployment with Publisher you’ll have access to the Reload tab for a task. This includes the option to add Script Parameters, which essentially leads to duplicate apps based on the provided field or variable name.
However – provide just one variable value, and you’ll pass this into one copy of the app.
We can pass a variable like vConfig = ‘qlikapp1~acme~dev’ and consume this in the QVW.
The data load script for QlikView is slightly different to the Qlik Sense script above as it uses SubField to break apart the vConfig variable, and creates an absolute path (relative paths can also be used and are generally best practice, but the example uses an absolute path to illustrate the point):
// Config // Set app-specific variables to determine data connection access // Set the customer code (e.g. acme, widgetcorp, etc) LET vConfig_Customer = SubField(vConfig,'~',2); // Set the product code (e.g. qlikapp1, qlikapp2, etc) LET vConfig_Product = SubField(vConfig,'~',1); // Set the environment code (e.g. dev, test, uat, prod, etc) LET vConfig_Environment = SubField(vConfig,'~',3); // Build root path for use across app SET vPath_Dir_Root = '\\qlikserver\QlikData\$(vConfig_Environment)\$(vConfig_Product)\$(vConfig_Customer)\';
This will build a path for \\<server name>\<qlik share>\<environment>\<product>\<customer>\
We can then use this to set titles, load further config (if we add in a value for locale, for example), or set the source and target for loading and saving data files onto disk, by using $(vPath_Dir_Root) in our LOAD…FROM and STORE…INTO statements.
With regards to directory management, a best practice is to construct additional variables from the vPath_Dir_Root to create pointers to the different QDF resource folders. See my earlier post which talks about the value of frameworks.