Skip to main content Skip to complementary content

Custom scripts

Use a block Custom Script in your automation to add your own custom code.

If this block is not available for your account, contact your account manager or Qlik Application Automation for OEM support to enable this feature. SaaS Admins can activate this feature per customer account by going to Edit Account.

You can use PHP, Python or Node.js (Javascript) code in the script.

The script must use a JSON-encoded print/echo (or equivalent), which will be the output of the Custom Script block.

Example custom scripts

Below are some example scripts, where the input for the script which is passed is an array.

Example script in PHP

foreach($inputs as &$input){
  $input = trim($input);
}
echo json_encode($inputs);

Example script in JS

inputs = inputs.map(input => {
   return input.trim()
})
console.log(JSON.stringify(inputs))

Example script in Python

import json
map(str.strip, inputs)
print(json.dumps(inputs))

Externally hosted custom code

The Qlik Application Automation for OEM Custom code block does not support including libraries. If you want to add comprehensive custom code to your automation and include e.g. libraries, you should host your custom code externally.

An easy solution is to use repl.it to host your code. Repl.it offers a free account but you need to upgrade to a paid account in order to make your code private.

Here's an example of a Repl in repl.it of type PHP Webserver to host some PHP code, which is exposed using an HTTPS URL:

A Repl page connected to an automation.

A Repl page connected to an automation.

PHP code from the above script:

$input=json_decode(file_get_contents("php://input")); //get inputs from Blend
//add logic here
echo json_encode($input); //send response back to automation

Copy the unique URL of your Repl and use it in a block Call URL to include it in your automation:

an automation connected to a Repl.

an automation containing a Call URL block which links to the above repl.

Obviously you will need to add security checks to avoid unauthorized access to your hosted code, and you have to make sure to use a private Repl (requires a paid account).