Skip to main content

Official Support Articles

Search or browse our knowledge base to find answers to your questions ranging from account questions to troubleshooting error messages. The content is curated and updated by our global Support team

Announcements
Welcome to Qlik Community! Check out our new navigation! FIND OUT MORE

Triggering an automation from a button on a sheet

cancel
Showing results for 
Search instead for 
Did you mean: 
NikoNelissen-Qlik
Contributor
Contributor

Triggering an automation from a button on a sheet

Automations can be linked to buttons on a sheet in a Qlik Sense app. Each time the button is clicked, the automation will run. This is a great way to automate manual tasks that the user would need to do during or after viewing the analytical data.

This scenario contributes to the Active Intelligence vision and allows you to convert "passive" analytics consumption to "active" actions that take place in real-time. These actions can be as simple as sharing a metric on Slack or Teams or in an email. Or they can create or update data directly in a business application such as Salesforce.

Example use case

Sarah - a sales manager - is reviewing the status of all sales opportunities on a sheet. She identifies a few outliers: sales opportunities with a high value that were not followed up recently. She makes a selection of the outliers and clicks a button "Increase priority". The button is linked to an automation that will immediately run in the background. The automation connects to Salesforce and creates follow-up tasks for each of the selected opportunities, avoiding the need for Sarah to manually find each of the opportunities in Salesforce and having to create the tasks manually. Sarah saves 4 hours every week by automating the follow up of her pipeline !

Linking a button to an automation

There are 2 ways to link a button to an automation:

  1. Opening the detail page of an automation when the button is clicked
  2. Executing the automation in the background when the button is clicked

Opening the detail page of an automation when the button is clicked

Add a navigation to the button of type "Open website or email" and copy/paste the URL of the detail page of the automation:

Button navigates to automation.png

When the button is clicked, the detail page of the automation will open in the browser. The user can now click the "Run" button to manually execute the automation. This scenario is useful if the automation requires human interaction, e.g. if it has inputs that the user needs to enter, or when the automation has output for the user to see.

In this scenario the automation cannot apply the current selection in the sheet. See the second scenario below if this is required.

Executing the automation in the background when the button is clicked

Add an action to the button of type "Execute automation" and select the automation to run in the dropdown box:

Button to execute automation.png

 

When the user clicks the button, the automation will run in the background.

Check the box "Include selections" if you want to apply the current selection of the user in the automation. If this checkbox is checked, the button will create a bookmark each time the button is clicked, and it will send the app id and bookmark id to the automation.

The automation MUST have an input block directly below the Start block with 2 inputs of type text. Name these inputs e.g. "application" and "bookmark":

inputs.png
Add a block "Apply bookmark" that uses these inputs:
 
apply bookmark.png
Note: add a Sleep block above the Apply Bookmark block, which sleeps for at least 5 seconds. The bookmark is not available immediately after creation, this Sleep button avoids "racing conditions".
 
Now you can fetch data from the sheet, e.g. using the block "Get straight table data", and you can process this data to e.g. create records in a business application or to share a metric in Slack, Teams or email. Note that the bookmark will be applied to the data fetched from the table. Finally, make sure to delete the bookmark, to avoid ending up with a large amounts of bookmarks:
 
delete bookmark.png

Send feedback to the user

If you want to provide feedback to the user from within the automation - e.g. how many records were updated in Salesforce by the automation - you could use a "Text & image" component on the dashboard and a variable.
 
First, define a new variable in Qlik Sense, e.g. "feedbackText". Next, add a "text & image" component to the dashboard, and link it to the variable by setting its expression AND label to "=feedbackText":
 
Text component linked to variable.png

Add a block to the automation "Update variable" and set its definition to the feedback text, e.g. "Data was updated". Add a block "Save app" (this is important to see the update of the variable in the user session instantly):

Update variable to provide user feedback.png

Now if the automation runs, the text will be visible to the user on the dashboard, providing an easy feedback loop:

Fedback on dashboard.png

Labels (2)
Comments
cotiso_hanganu
Partner - Creator II
Partner - Creator II

Sounds promising 

Tx  for sharing, Niko !

cotiso_hanganu
Partner - Creator II
Partner - Creator II

First attempt to do the 2nd option didn't worked yet.
It seems to me there is a part that is not a very  intuitive behaviour:
the way the AppId and the Bookmark is handled further to Qlik Automation seems more like a workaround, rathar than a strong solution.
But hey, if it will work... it's cool enough !

Will come back later with more comments.

cotiso_hanganu
Partner - Creator II
Partner - Creator II
blaise
Partner - Specialist
Partner - Specialist

I also hoped for a better solution but it hey - it works! Seems like you (qlik) needs to do some more coding before its production ready. I had issues with the apply bookmark even with a 10 sec sleep so I added the applybookmark to a loop and checked the {$.applyBookmark.qSuccess} eq. true before continue with the rest of the automation. One time it took 1m46 sec (5 sec loop) before the automation was able to apply the bookmark.

cotiso_hanganu
Partner - Creator II
Partner - Creator II
tts
Employee
Employee

You need to put [Save App] block after [Delete Bookmark] block to do the deletion.

tts
Employee
Employee

My idea about how to wait completion of [CreateBookmark] API, please try to put [List Bookmarks] block in a loop and check the existence of the bookmark which were requested by Action button.

blaise
Partner - Specialist
Partner - Specialist

@tts  - are you really sure that you need the Save App block? My tests conducted 2 weeks ago showed that I didn't have to save the app.

tts
Employee
Employee

>are you really sure that you need the Save App block?

yes. I tested this case with current tenant. But, I guess the need of the block depends on Qlik Application Automation implementation on a tenant...

blaise
Partner - Specialist
Partner - Specialist

Strange, just ran my "delete bookmark" automation (eu tenant) and the bookmarks are deleted, at least accourding to ListBookmark;

blaise_0-1636548520995.png

and the result;

blaise_1-1636548583982.png

 

 

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