Early Access: The content on this website is provided for informational purposes only in connection with pre-General Availability Qlik Products.
All content is subject to change and is provided without warranty.
Skip to main content Skip to complementary content

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.

Template apps must have their sheets made public for other users to generate on-demand apps. For more information, see Granting access to sheets, sheet groups, bookmarks, and stories.

Information noteAn on-demand template app does not load data directly. The template app connection must be valid, but to test whether the connection works correctly, you must generate an on-demand app. When an on-demand app is generated, the load script is modified by the On-demand app service to load the selection state of the on-demand selection app. If the on-demand app generates without error, then you know the connection in template app work correctly.
Information noteConsider the size of your apps when developing on-demand template apps. Depending on your deployment, there may be storage limits, or using a large amount of storage may cause your cloud deployment to scale. Contact your system administrator for more information.

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.

Information note

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:

$(odag_FIELDNAME)

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.

Information note

If you change the script of your template app and insert a new binding variable, new on-demand app navigation links must be created to replace any existing app navigation links. If you do not, the selection for the corresponding field will not be sent for existing on-demand apps using that template app.

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.

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:

///!ODAG_SSO

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.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!