<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article How to handle tasks reporting wrong status when executing external program. ie.Powershell in Official Support Articles</title>
    <link>https://community.qlik.com/t5/Official-Support-Articles/How-to-handle-tasks-reporting-wrong-status-when-executing/ta-p/1775681</link>
    <description>&lt;P&gt;When using an external program to run a task as described&amp;nbsp;&lt;A title="here" href="https://community.qlik.com/t5/Support-Knowledge-Base/Qlik-Sense-Create-an-external-program-running-a-Powershell/ta-p/1713044" target="_blank" rel="noopener"&gt;here&lt;/A&gt;, the execution might fail but&amp;nbsp;&lt;SPAN&gt;the status of the external task in the QMC might not get updated accordingly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;In order to handle the failed execution, it's needed to send a request that updates the status in the QMC.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Here is an example of how to update the status in the QMC:&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;&lt;STRONG&gt;Optional step&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you want to change a specific execution you can use the following code to retrieve the ID needed to change the task status&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;$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 
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected response:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;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         : 
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;With the id retrieved we can go ahead and change the result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;$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'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;SPAN&gt;Possible values for task "status" are:&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;LI-CODE lang="markup"&gt;"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"&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;Environment&lt;/H4&gt;
&lt;H6&gt;&amp;nbsp;&lt;/H6&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;LI-PRODUCT title="Qlik Sense Enterprise on Windows" id="qlikSenseEnterpriseWindows"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Powershell&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;Related Content&amp;nbsp;&lt;/H3&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/November2020/Subsystems/RepositoryServiceAPI/Content/Sense_RepositoryServiceAPI/RepositoryServiceAPI-Example-Connect-Powershell.htm" target="_blank" rel="noopener"&gt;Connecting with Microsoft Powershell&lt;/A&gt;&lt;BR /&gt;&lt;A title="Qlik Sense - Create an external program running a Powershell Script " href="https://community.qlik.com/t5/Support-Knowledge-Base/Qlik-Sense-Create-an-external-program-running-a-Powershell/ta-p/1713044" target="_blank" rel="noopener"&gt;Qlik Sense - Create an external program running a Powershell Script &lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Mar 2021 09:29:25 GMT</pubDate>
    <dc:creator>Francisco_Fernandez</dc:creator>
    <dc:date>2021-03-25T09:29:25Z</dc:date>
    <item>
      <title>How to handle tasks reporting wrong status when executing external program. ie.Powershell</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/How-to-handle-tasks-reporting-wrong-status-when-executing/ta-p/1775681</link>
      <description>&lt;P&gt;When using an external program to run a task as described&amp;nbsp;&lt;A title="here" href="https://community.qlik.com/t5/Support-Knowledge-Base/Qlik-Sense-Create-an-external-program-running-a-Powershell/ta-p/1713044" target="_blank" rel="noopener"&gt;here&lt;/A&gt;, the execution might fail but&amp;nbsp;&lt;SPAN&gt;the status of the external task in the QMC might not get updated accordingly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;In order to handle the failed execution, it's needed to send a request that updates the status in the QMC.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;Here is an example of how to update the status in the QMC:&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;&lt;STRONG&gt;Optional step&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If you want to change a specific execution you can use the following code to retrieve the ID needed to change the task status&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;$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 
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected response:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;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         : 
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;With the id retrieved we can go ahead and change the result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;$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'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;SPAN&gt;Possible values for task "status" are:&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;LI-CODE lang="markup"&gt;"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"&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4&gt;Environment&lt;/H4&gt;
&lt;H6&gt;&amp;nbsp;&lt;/H6&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;LI-PRODUCT title="Qlik Sense Enterprise on Windows" id="qlikSenseEnterpriseWindows"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Powershell&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;Related Content&amp;nbsp;&lt;/H3&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/November2020/Subsystems/RepositoryServiceAPI/Content/Sense_RepositoryServiceAPI/RepositoryServiceAPI-Example-Connect-Powershell.htm" target="_blank" rel="noopener"&gt;Connecting with Microsoft Powershell&lt;/A&gt;&lt;BR /&gt;&lt;A title="Qlik Sense - Create an external program running a Powershell Script " href="https://community.qlik.com/t5/Support-Knowledge-Base/Qlik-Sense-Create-an-external-program-running-a-Powershell/ta-p/1713044" target="_blank" rel="noopener"&gt;Qlik Sense - Create an external program running a Powershell Script &lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 09:29:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/How-to-handle-tasks-reporting-wrong-status-when-executing/ta-p/1775681</guid>
      <dc:creator>Francisco_Fernandez</dc:creator>
      <dc:date>2021-03-25T09:29:25Z</dc:date>
    </item>
  </channel>
</rss>

