While this works perfectly well, the status of the Qlik Sense task in QMC is reflective on whether the QLik script code completed without error. If the script was able to successfully submit the publish task request, it will say success. But what if the NPrinting task that was triggered ran for an hour and then errored out ? Well, the reports would not be delivered and the Qlik Sense tasks would have still said success.
A trick to resolve this is to add a 'status check' into the same Qlik script that loops on an interval to see when the task completes. In the attached i added a configurable timeout, interval as well as a few other configuration variables to make the script more re-usable . Things like the NP server name, whether you are using http or https etc...
For now it only checks for a few of the possible status' and manually throws an error if things fail.
Below you will see the additional code in the 'Set Variables' section as well as the 'Check Status" section that make this possible.
THis way, the QLik task won't complete until
1. it hits the timeout you set
2. it succeeds
3. it fails
Whats not in there is 'killing' the NP task if its still running past the timeout. That can be cleaned up to using a 'patch' request on the NP task execution . I'll do that next time !