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.
• 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.
• 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:
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.