Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
Qlik Connect 2025! Join us in Orlando join us for 3 days of immersive learning: REGISTER TODAY

How to handle tasks reporting wrong status when executing external program. ie.Powershell

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Francisco_Fernandez

How to handle tasks reporting wrong status when executing external program. ie.Powershell

Last Update:

Mar 25, 2021 5:29:25 AM

Updated By:

Francisco_Fernandez

Created date:

Jan 22, 2021 10:34:09 AM

When using an external program to run a task as described here, the execution might fail but the status of the external task in the QMC might not get updated accordingly.

In order to handle the failed execution, it's needed to send a request that updates the status in the QMC.

Here is an example of how to update the status in the QMC:


Optional step

If you want to change a specific execution you can use the following code to retrieve the ID needed to change the task status

 

$hdrs = @{}
$hdrs.Add("X-Qlik-xrfkey","12345678qwertyui")
$hdrs.Add("X-Qlik-User","UserDirectory=DOMAIN;UserId=Administrator")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}
 
$url = "https://qlikserver1.domain.local:4242/qrs/executionresult?xrfkey=12345678qwertyui"
Invoke-RestMethod -Uri $url -Method get -Headers $hdrs -Certificate $cert # | ConvertTo-Json 

 

Expected response:

 

id                 : 1fc45154-954b-497f-8752-86aca2180ec4
executingNodeName  : 
status             : 0
startTime          : 1753-01-01T00:00:00.000Z
stopTime           : 1753-01-01T00:00:00.000Z
duration           : 0
fileReferenceID    : 00000000-0000-0000-0000-000000000000
scriptLogAvailable : False
details            : {}
scriptLogLocation  : 
scriptLogSize      : -1
privileges         : 

 

 


With the id retrieved we can go ahead and change the result:

 

$body = '{
  "status":"11",
  "modifiedDate":"2021-03-25T17:00:36.157Z"
}'
$hdrs = @{}
$hdrs.Add("X-Qlik-xrfkey","12345678qwertyui")
$hdrs.Add("X-Qlik-User","UserDirectory=DOMAIN;UserId=Administrator")
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where {$_.Subject -like '*QlikClient*'}

$url = "https://qlikserver1.domain.local:4242/qrs/executionresult/1fc45154-954b-497f-8752-86aca2180ec4?xrfkey=12345678qwertyui"
Invoke-RestMethod -Uri $url -Method Put -Headers $hdrs -Certificate $cert -Body $body -ContentType 'application/json'

 

Possible values for task "status" are:
"0: NeverStarted",
"1: Triggered",
"2: Started",
"3: Queued",
"4: AbortInitiated",
"5: Aborting",
"6: Aborted",
"7: FinishedSuccess",
"8: FinishedFail",
"9: Skipped",
"10: Retry",
"11: Error",
"12: Reset"

 

Environment

 

 

Related Content 

Connecting with Microsoft Powershell
Qlik Sense - Create an external program running a Powershell Script  

Version history
Last update:
‎2021-03-25 05:29 AM
Updated by: