Creating an on-demand template app
An on-demand template app is a regular Qlik Sense app with one important difference: its load script contains data binding expressions used to formulate the queries made on the data sources. These data binding expressions are used at on-demand app generation time to read values from the selection state of the selection app and bind them to the template app script so that the generated app is loaded with a user-controlled subset of the data.
The template app typically connects to the same data source as the selection app. The load script of a selection app typically loads aggregated data to reduce data volumes while still offering interactive visualizations of important dimensions and measures. The load script of a template app uses queries that load a controlled subset of more granular data.
Structure of a template app
A template app is linked to a selection app using an on-demand app navigation link. The app navigation link includes properties that control the number of records queried when the on-demand app is loaded with data. The load script of the template app contains data binding expressions that specify which field data from the selection app is used to formulate the queries issued when loading data into the on-demand app.
A new syntax for data binding expression was introduced in June 2020. The previous syntax and prefixes od_, ods_, odo_, odso_, and odb_ behave as before including quantity constraints, _n suffix, and format specifications. If your app should work on Qlik Sense versions prior to June 2020, use the old syntax. For the old syntax, see Creating an on-demand template app (old version).
The _n suffix is not supported when using the new prefixes.
Basic data binding expressions have the form:
The odag_ prefix is used to bind the selection state of the selection app to the load script of the on-demand app, which is created by copying the template app. The part of the data binding expression that follows the odag prefix must be a name that matches a field in the selection app. When the on-demand app is generated, the current selection state of the selection app is used to obtain the desired values to bind for each field. Each occurrence of a $(odag_FIELDNAME) expression in the load script of the newly created on-demand app is replaced with the list of values selected for the corresponding field in the selection state of the selection app.
Other prefixes for more specialized data binding are available. To learn more about tailoring for special cases and optimizing load statements, see Binding expressions in on-demand template apps.
On-demand bindings can be inserted directly into SELECT and WHERE statements in your load script. When you add bindings directly into your WHERE statements, it is easy to combine them with other conditions in the statement.
You can add a placeholder variable $(odagActive) when making your load script. This enables you to load sample data into the template app so that master charts for dynamic views can be created without loading all data.
The following examples illustrate a sample on-demand template load script.
Example: Adding some sample data
This example adds sample values so the app can be loaded even if the bindings are not complete.
IF '$(odagActive)'='' THEN trace ODAG variables not inserted! Loading sample data.; SET 'odag_Origin Code' = '''LAX'''; SET 'odag_Destination Code' = '''JFK'''; SET odagn_Year = 2015; SET odag_Quarter = '''1'''; SET 'odag_Ticket Carrier Code' = '''CA'''; SET 'odag_Fare Class' = '''X'''; END IF;
Example: Loading data in the template app
The following is a sample load script for loading the sample data and filtering it with the generated odag_FIELDNAME bindings. The odagn_<Field Name> bindings pick the numbers in the duals and uses by default no quoting.
SQL SELECT * FROM FlightDB.Flights WHERE "Origin Code" IN ($(odag_Origin Code)) AND "Destination Code" IN ($(odag_Destination Code)) AND "Year" IN ($(odagn_Year)) AND "Quarter" IN ($(odag_Quarter)) AND "Ticket Carrier Code" IN ($(odag_Ticket Carrier Code)) AND "Fare Class" IN ($(odag_Fare Class));
Single Sign-On (SSO)
On-demand apps can use single sign-on (SSO) with data sources that support SSO. The engine and the data source must be configured to allow SSO.
For more information, see Configuring SAP HANA for SAML Single Sign-On with Qlik Sense and Configuring Cloudera Impala for Single Sign-On.
Once the engine and data source have been configured for SSO, the template app must enable SSO by adding the following syntax to the template app script:
The On-Demand App Service parses the script when an on-demand app is generated and each time it is reloaded.
When an on-demand app is loaded with SSO, the identity of the end user is sent to the data source. The end user must have access to the sources used in the template app's data connections. Only data that user has access to in those sources is loaded, even if a larger set of data is selected.
Reload nodes for template apps
Administrators can control where on-demand apps are reloaded in a multi-node environment by setting load balancing rules on template apps. When a load balancing rule is set, all apps generated from links to the template app will be loaded according to the rule that applies to the template app. For more information, see Managing on-demand apps.