Qlik Community

Knowledge

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
Support Case Portal has moved to Qlik Community! Read the FAQs to start exploring Support resources.

How to: task chaining with Qlik Application Automation

Emile_Koslowski
Support
Support

How to: task chaining with Qlik Application Automation

This article explains how to perform task chaining for your QCS apps using Qlik Application Automation. It'll start with a simple app reload example and finishes with a complex task chain example.

Covered topics:

  1. Reloading QCS apps
  2. Sync vs async reloads
  3. Basic task chain
  4. Task chain with condition
  5. Task chain with a loop
  6. Task chain with a loop and condition

1. Reloading QCS apps

Create a new automation and follow these steps to reload a QCS app:

  1. Go to the Qlik Cloud Services connector and search for the "Do Reload" block. Drag this block inside the editor and attach it to the Start block.
  2. Click on the newly added block to highlight it and display the block details menu on the right side of the editor. Go to the inputs tab of this block and enter the App Id for the QCS app you want to reload.
  3. It is also possible to do a lookup for your app. Click the empty input field for App Id and click "Do Lookup" in the dropdown that appears. This will fetch a list of all the QCS apps you have access to, select the app you want to reload. 
  4. For now, you can ignore the other input fields. Click the green Run button to execute the automation.

Example blend: 

Emile_Koslowski_0-1626357314473.png

 

Result in the editor:

Emile_Koslowski_1-1626357678369.png

The output from the Do Reload block contains information about the reload. The "status" field for example will indicate whether the reload was successful.

2. Sync vs async reloads

Reloads can either be done synchronous or asynchronous. This is configured by selecting a value for the field "Run Mode" in the inputs tab of the Reloads block.

Emile_Koslowski_2-1626358017453.png

Async: set the Run Mode to "Start reload and continue". When executed, the block will trigger a reload and output the reload id. The automation will continue immediately. Use the reload id in the block "Get Reload Record" to get the reload's status.

Sync: set the Run Mode to "Wait for reload to complete". When the block is executed, the automation won't continue until the reload is finished. Once the reload is finished the block will output the reload's result and the automation will continue.

3. Basic task chain

Now for a basic task chain, drag an additional "Do Reload" block in the editor and attach it to the automation.

  1. Go to the Inputs tab in the first Reloads block and set the Run Mode to "Wait for reload to complete". This way, the second reload block will only execute once the first reload block is finished.

Emile_Koslowski_3-1626359029010.png

4. Task chain with a condition

In the previous example, the second reload will always execute once the first reload is finished. Regardless of the result. In some cases, you might only want to start the second reload when the first reload finished successfully.

  1. Search for the "Condition" block and attach it between the 2 reload blocks.
  2. Go inside the inputs tab on the Condition block and set the Input field of the "if" statement. From the dropdown that appears, select "output from Do Reload" and click on the "status" field.
    Emile_Koslowski_4-1626359328070.png
  3. Next, select the condition of the "if" statement and set it to "equals". A new input field will appear. Here you should specify the value you expect to receive in the Reload's status field. In this example, we only want to do the second reload if the first one was successful so we'll set this value to "SUCCEEDED".
  4. Now drag the second Do Reload block to the "Yes" part of the Condition block. 
  5. Finally, add a comment to the Condition block so its function is clear without having to open it and look at the actual condition.
  6. The automation should look like this:

Emile_Koslowski_5-1626359696776.png

A JSON file containing the above automation is attached to this article as basic_task_chain.json. How to import an automation

Bonus: feel free to add functionality to the "No" part of the Condition block. Maybe use the Email connector to send out an email or send a message to a channel in Slack .

5. Task chain with a loop (parallel task chain)

In some cases, you'll want to trigger multiple app reloads to start simultaneously. And wait for all of them to finish before continuing the automation.

  1. Clear your automation or create a new one and drag a "Variable" block in it. This variable will contain a list of app ids for all the apps to reload.
  2. Go to the Inputs tab on the Variable block and click the "Manage variables" button to add new variables. Add a variable of name "AppIds" and type "List". Click Save.
  3. Select the new variable as the value for the Variable input parameter in the Inputs tab.
  4. Click "Add operation" in the variable's input tab and select "Empty AppIds" as the first operation that needs to happen when this block is executed. It's a good practice to empty a variable before using it.
  5. Add a new operation, this time select "Add item to AppIds". Enter the id of one of the apps that need to reload.
  6. Repeat the above step 5 for each app that needs reloading.
    Emile_Koslowski_6-1626360613552.png
  7. Next, we'll need to loop over the list of app ids. Search for the "Loop" block and attach it to the Variable block.
  8. Go to the inputs tab of the Loop block and specify the list variable. (This should have happened automatically)
  9. Search for a "Do Reload" block and add it to the automation inside the loop of the Loop block.
  10. Go to the inputs tab of the Do Reload block and map the App Id field to the Item in the loop. Set the Run Mode to "Start reload and continue".
    Emile_Koslowski_7-1626360880620.png

     

  11. Now we somehow need to keep track of the ids of all the reloads that were started. To do this, add a new variable block to the automation right after the "Variable - AppIds" block. Again, go to Manage variables and add a new variable with the name "ReloadIds" and type "List". Set this variable as the active variable in the Variable input parameter and add "Empty ReloadIds" as an operation.
  12. Drag another Variable block inside the automation and add it right after the "Do Reload" block in the loop.
  13. Select ReloadIds as the Variable for that block. And add a new operation "Add item to ReloadIds". Click the input field for the Item's value and select the Id that's returned from the "Do Reload" block.
    Emile_Koslowski_2-1626361775023.png
  14. The next block we'll need is the "Wait For Reloads To Complete" block from the Qlik Cloud Services connector. Add this block to the automation after the loop.
  15. Go to this block's inputs tab and map the ReloadIds list variable to the "Reload Ids" input parameter. This input parameter expects a comma-separated list. So after mapping it, click the ReloadIds mapping and select "Add Formula".
    Emile_Koslowski_3-1626361904923.png
  16. Search for the "Implode" formula and select it. This formula will transform the list into a comma-separated string. Click "Save" to add the formula. 
  17. Bonus: feel free to add a "Send Email" block from the Email connector or send a message to a channel in Slack . To notify people of the finished reloads.
    Emile_Koslowski_4-1626362246570.png

6. Task chain with a loop and condition

This part continues on the automation that was created in part 5. "Task chain with a loop". 

In most use cases, what happens after the parallel reloads will depend on the returned results. To do this, we'll need to filter the results from the "Wait For Reloads To Complete" block.

  1. Search for the "Filter List" block and attach it after the Wait For Reloads To Complete block.
  2. Map the output from the Wait For Reloads To Complete block as input for the List parameter. And set the condition to "If status does not equal SUCCEEDED". Now the Filter List block will output all the unsuccesful reloads.
    Emile_Koslowski_5-1626362607304.png
  3. Next, add a Condition block after the Filter list block. Set the condition to "If Filter List is empty". If this condition is true, (the Yes part) then all reloads were successful. Else (the No part) some reloads failed.
    Emile_Koslowski_7-1626362935194.png
  4. Feel free to fill in both the Yes and No part of the Condition block, depending on your use case.
    1. Maybe you want to start a new reload only if all reloads were successful? Then add a new Do Reload block to the Yes part of the condition.
    2. Or if you want to alert your team on the result, you can use blocks from the Email, Slack, or Teams connectors to populate both the Yes and No part

Emile_Koslowski_8-1626363044282.png

 

A JSON file containing the above automation is attached to this article as parallel_task_chain_with_condition.json How to import an automation

Labels (2)
Attachments
Version history
Revision #:
1 of 1
Last update:
‎2021-09-06 09:17 AM
Updated by:
 
Contributors