Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE

How to use the Save App block in Qlik Application Automation

100% helpful (1/1)
cancel
Showing results for 
Search instead for 
Did you mean: 
Emile_Koslowski
Employee
Employee

How to use the Save App block in Qlik Application Automation

Last Update:

Dec 20, 2023 7:21:06 AM

Updated By:

Emile_Koslowski

Created date:

Feb 8, 2022 6:04:50 AM

This article explains how the Save App to block can be used to distribute changes made in an automation's session to other sessions (for example, the Qlik Sense UI). Before you continue with this article it is advised to have a good understanding of how Qlik Application Automation interacts with the Qlik engine and the QIX API. This article is a good start for that: Automation session delays.

Engine sessions recap

As explained in the session delays article, automations will create sessions for certain interactions with apps. When this is done, the following rule applies:

An automation creates a unique session per automation, per run, per app.

The changes made by these operations are scoped to the automation's session and will only be distributed to other sessions (including the Qlik Sense UI) after 20-40 minutes.

In some situations, you might want to make these changes available immediately in the other sessions. To do this, the Save App block can be used. 

Save App

The Save App block will execute the DoSave method in the QIX API. This method will save an app, its objects, and data in the data model from the current session. And it will load the app again in all open sessions.

The usage of this block has two drawbacks:

  1. It's computationally heavy
  2. It's limited to one execution/session/automation

Heavy computation

This can be computationally heavy and should only be done we the changes need to be distributed immediately to all active sessions. Know that they will eventually sync automatically after 20-40 minutes.

Only one execution/session

The usage of the Save App block is limited to one execution for every active session. In the context of an automation, this translates to one execution for every app that was modified by a session block. It's advised to execute the Save App block once for every affected app at the end of your automation.

If the Save App block is used multiple times for the same session, it will only work the first time.

A list of blocks that use the QIX API (session blocks) can be found at the end of this article.

More info on the DoSave method can be found here.

Examples

1. Basic

In the below example, a few measures are added to an app. The Create Measure block is a session block, so its changes aren't immediately distributed to other sessions.

Emile_Koslowski_0-1643985158914.png

We can use the Save App block to distribute these changes. And since all changes are made to the same app, only one session is used and the Save App block needs to be executed only once.

Emile_Koslowski_1-1643985199118.png

 

2. Multiple sessions

The automation in the below example will create a new measure in two different apps. This means the automation will create two sessions, one for every app.

Emile_Koslowski_2-1643985270939.png

So the Save App block needs to be executed twice.

Emile_Koslowski_3-1643985325999.png

3. Loops

In this example, we'll list measures from a source app and distribute (create or update) them to all apps in a space. This automation will create the following sessions:

  • one for listing the measures
  • one for every app in the target space

Emile_Koslowski_4-1643985520090.png

 

No changes are made to the source app, so session distribution is not required, executing a Save App block for this app is a waste of resources.

To make sure a Save App block is executed for every created measure, we can add this block as the last step inside the loop:

Emile_Koslowski_5-1643985555752.png

4. Multiple loops

This time, we'll use 2 source apps and we'll distribute their measures again to all the apps in a target space. As you see in the example below, it's not feasible to add the Save App block after the Create Measure block as it will be executed multiple times for the same application (which won't work as explained in the previous section).

Emile_Koslowski_6-1643985738072.png

You'll probably be able to rewrite the above automation so it has a place for the Save App block. But that won't always be an option, especially for bigger automations. Trying to fit in a Save App block in the middle of an automation will also increase its complexity.

The easiest solution here is to list the apps from the target space again at the end of the automation and execute the Save App block in the List Apps block's loop.

Emile_Koslowski_8-1643986548180.png

 

 

The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.

Related Content

Automation session delays

Labels (2)
Version history
Last update:
‎2023-12-20 07:21 AM
Updated by: