Skip to main content

How-to: Performing Selections in a Qlik Sense App using Qlik Application Automation

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
MarkGeurtsen
Support
Support

How-to: Performing Selections in a Qlik Sense App using Qlik Application Automation

Last Update:

May 10, 2022 1:43:00 PM

Updated By:

Jamie_Gregory

Created date:

Sep 22, 2021 3:17:44 AM

Attachments

In an automation in Qlik Cloud it is possible to work with Qlik Sense apps and obtain data from tables, with the use of selections the data that is inside a table can be filtered.
Because these selections happen in a different session than the one used in the UI, odd behavior might be going on for the user. This article is meant to explain how to use selections, it's limitations and best practices.

Automations in Qlik Cloud provide end users with capabilities to work with Qlik Sense apps in different ways. Different usecases depend on the capability run automations on a specific app and applying different selections. After selections have been applied on an app, it is possible to obtain data from charts, for example by making use of the Get Straight Table Data block. The data that is returned by this block depends on the different selections that are made. This enables end users to perform actions depending on the filtered data, for example sending out a Teams or Slack message.

The Qlik Cloud connector has the following blocks which can be used for selections:

Select Field Value
This block performs a selection. It takes a field name and field value as inputs. One field value can be selected for a field. Furthermore it is possible to lock the field value. If a selection is made successfully, this block will return a JSON object with the qResult set to true.

Select Field Values by Query
This block performs a selection. It takes a field name and field value search string as inputs. Using a query it becomes possible to select multiple values for as selections for a field. Furthermore it is possible to lock the field value. If a selection is made successfully, this block will return a JSON object with the qResult set to true.

Clear all selections
Clears all current selections inside an app. It has an option to force an unlock on locked selections. If a field is locked, but "Clear locked fields" is not selected, the locked selection will stay.

Clear Selection
Clears a single selection, this is done by providing the field name. If a field is locked, but "Clear locked fields" is not selected, the locked selection will stay.

Lock Field
Creates a lock on a selected field. This prevents conflicting selections from being made.

Lock Selection
Creates a lock on all current selections. This prevents conflicting selections from being made.

Unlock Field
Removes a lock on a selected field. This frees up other values in this field.

Unlock Selection
Removes all current locks on all current selections.

Limitations


• Currently it is difficult to select multiple values for a field. This can be somewhat done through the use of the "Select Field Values by Query" block.
• It is not possible to view the current made selections. This functionality is currently being worked on.



Best practices


• Wherever possible, first use the Clear All Selections block with the Clear locked fields option enabled. This is to prevent your app being in a state where unwanted selections are already made.
• When you make a selection that has to stay, regardless of other selections on other fields being made, make sure the "Lock Field after Selection" is enabled.
• When you make subsequent selections where it's important to have all selections set, create a condition block which checks the qResult value of the select field value blocks.
• Manual behavior of locks can be done through the Lock Field or Lock Selection blocks. These serve to provide end users with more fine grained control on locking their selections.

Example app with automation


The example app attached to this article has five data rows with two columns, brand and color for cars. See table below:

Brand Color
Ferrari Red
Volkswagen Blue
Volkswagen Red
Volkswagen Black
Ferrari Red

 

The first automation named ferrari_block_no_lock
s.json, attempts to first set the field Brand to Ferrari followed by the field Color to black without applying locks. The result is a black Volkswagen. The second selection was not possible with the Brand set to Ferrari, hence why the first selection was made undone.

The second automation named ferrari_red_locks.json, does the same as the first automation, however a lock is applied on the Brand and on the Color. The first selection gets locked on Ferrari and the second selection fails. The end result is two red Ferrari's.

The third automation named conditional_error.json, does the same as the second automation, but a condition is added to the automation. After applying the second selection, a condition verifies if the qResult of the output of the second selection is set to true. The qResult indicates whether the selection was applied successfully.

 

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.

Labels (1)
Comments
jmbenedetto
Employee
Employee

Hello @MarkGeurtsen !

Thanks for the article.

I have an use case where:

- many users share an app;

- the user can make selections on sheet and press a button to run an automation.

- the filter sometimes are done in calculated dimensions.

- I need to apply the same filters on the automation side.

The solution I'm putting together:

- Because only the automation owner can run the automation from a button, I'm calling it via webhook.

- To include the selections, I'm using GetCurrentSelections() and appending the return to the api call.

- I apply the selections using the block Select Field Value.

My problem:

I have some calculated dimensions like this:

=if([As Of Date] > '11/30/2021',[Customer Name])

When the user filter by this dimension, GetCurrentSelections() returns:

If([As Of Date]>'11/30/2021',[Customer Name])=Abbott-Nitzsche - 1

I tried to use if([As Of Date] > '11/30/2021',[Customer Name]) as Field name, but it does not work. Could you please advise?

Best regards

 

Version history
Last update:
‎2022-05-10 01:43 PM
Updated by: