Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. READ MORE

Calling QlikView Tasks from Qlik Sense on-prem

cancel
Showing results for 
Search instead for 
Did you mean: 
marksouzacosta
Partner - Specialist
Partner - Specialist

Calling QlikView Tasks from Qlik Sense on-prem

Last Update:

May 22, 2024 2:40:31 PM

Updated By:

marksouzacosta

Created date:

May 22, 2024 3:05:36 PM

Introduction

QlikView > Qlik Sense > Qlik Cloud...
Replatform is challenging and sometimes, different platforms have to coexist and interact to each other.

In this article I will show how can you call QlikView Tasks from Qlik Sense - and potentially from Qlik Cloud - using PowerShell Scripts.

 

Requirements

  • QlikView and Qlik Sense Servers must be accessible to each other
  • Qlik Sense Service User Account must have QlikView QMC rights to execute tasks
  • Qlik Sense Legacy Mode enabled - More info: Disabling standard mode | Qlik Sense on Windows Help
  • PowerShell installed and enabled to execute scripts
# Open Powershell as Admin and Execute the following to allow Powershell Scripts execution
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
# Set-ExecutionPolicy Unrestricted

 

The PowerShell Script

The PowerShell script is simple as it shows below. It requires two parameters:

  1. The QlikView QMC Service URL: usually in the form http://myqlikurl:4799/QMS/Service
  2. The QlikView Task ID: this is a Task ID GUID number. You can get the Task ID from QlikView QMC Task Log - probably there are other ways to get this GUID too.

 

 

param (
    [Parameter(Mandatory=$true)]
    [string]$QlikViewQMCServiceUrl,
    [Parameter(Mandatory=$true)]
    [string]$TaskID
)

$service = New-WebServiceProxy -Uri $QlikViewQMCServiceUrl -Namespace QlikViewServer -UseDefaultCredential 
$serviceKey = $service.GetTimeLimitedServiceKey()

$hdrs = @{}
$hdrs.Add("SOAPACTION","http://ws.qliktech.com/QMS/12/2/IQMS2/RunTask")
$hdrs.Add("Content-Type", "text/xml;charset=utf-8")
$hdrs.Add('X-Service-Key',$serviceKey)

$body = @{}
$body = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<RunTask xmlns="http://ws.qliktech.com/QMS/12/2/">
<taskID>' + $TaskID + '</taskID>
</RunTask>
</s:Body>
</s:Envelope>'

$res = Invoke-WebRequest -Uri $QlikViewQMCServiceUrl -Method Post -Body $body -UseDefaultCredential -Headers $hdrs

 

 

Running the PowerShell Script

We can Run the PowerShell Script in multiple ways:

  • CMD
  • PowerShell
  • Batch Files
  • Qlik Sense Task
  • Qlik Sense Load Script
  • SQL Server Stored Procedures
  • Any other platform that supports PowerShell scripts

For now, we'll run it through Qlik Sense Load Script:

 

EXECUTE powershell.exe -ExecutionPolicy Bypass -File "$(vTempPowerShellScriptFile)" -QlikViewQMCServiceUrl "$(vTempQlikViewQMCServiceUrl)" -TaskID "$(vRunningTask)";

 

 

To call the EXECUTE statement in the Load Script you must enable the Legacy Mode in your Qlik Sense Server.

  • vTempPowerShellScriptFile is the full path of the PS1 PowerShell Script file
  • vTempQlikViewQMCServiceUrl is the QlikView QMC Service Url
  • vRunningTask is the QlikView Task ID

That is it! Now from Qlik Sense Server we can call QlikView Tasks with minimum changes in our server environments.

 

Enhancing the PowerShell Script

The PowerShell Script in my example contains only the core of its functionality. I strongly recommend including log messages and error handling through try/catch/finally blocks.

 

What about Qlik Cloud?

I haven't tested this but here is my theory:

  1. Have a SQL Server on-prem with access the QlikView Server
  2. Create a Store Procedure with the same parameters of the PowerShell Script. The Stored Procedure will execute the PowerShell Script.
  3. Install and configure Qlik Data Gateway on a server with access to the SQL Server Database
  4. On Qlik Cloud setup a SQL Server connection based on the Qlik Data Gateway
  5. From Qlik Cloud, create a Qlik Sense Application that calls the Stored Procedure from the Load Script - For more info: Solved: Qlik Data Gateway with SQL Stored Procedures - Qlik Community - 2001425

That should do the magic. Please let me know if you have tried this and if it has worked.

Comments
igoralcantara
Partner - Creator III
Partner - Creator III

This is very good! Thank you for sharing.

Contributors
Version history
Last update:
‎2024-05-22 02:40 PM
Updated by: