Skip to main content
Announcements
Document boards are being consolidated, this board no longer allows NEW documents READ MORE

How to manage your NPrinting task execution from QlikView script

cancel
Showing results for 
Search instead for 
Did you mean: 
Yang_Jiao
Support
Support

How to manage your NPrinting task execution from QlikView script

Last Update:

Sep 21, 2022 5:11:51 PM

Updated By:

Sue_Macaluso

Created date:

Jun 3, 2018 4:00:59 PM

Attachments

Recently I have heard this question several times, therefore it might be worth of writting something about it.

Since version 17.2, NPrinting has empowered its features to external programs by its RESTful APIs. User may easily control and get data from the system with the APIs now. It is a very popular scenario that user wants to start the NPrinting Publish task right after the data reload is done in the QlikView application, so that the published report will have the latest data.


There are several possible ways to it. In this example you will find how to trigger and monitor the NPrinting task through QlikView load script, which requires nothing more than a QlikView Desktop and a Qlik REST connector, besides of the NPrinting environment. In the end of this article you will also see how to chain it with a QlikView document reload task in the QMC, so that the NPrinting task will automatically start right after the QlikView reload task is finished.


Some prerequisites for using this example:

  1. Qlik NPrinting June 2017 and later
  2. Qlik REST Connector 1.3
  3. A publish task has been configured correctly with successful report generation in NPrinting (help)
  4. A user has been configured correctly in NPrinting with proper security priviliges, and linked to a Windows Domain user (help)
  5. In order to allow HTTP POST access from QlikView server to NPrinting server, QlikView server’s hostname has been added to the NPrinting Trusted Origins (help)

And this article might be helpful with more information regarding to using NPrinting APIs.

The attached QlikView application in this example is quite self-explanatory. Here I will just list some key components for your attention.

  1. Authentication: First I create a POST request for NTLM authentication (POST /login/ntlm). This is because the later request for triggering the task is a POST request. And Qlik REST connector cannot mix between a GET connection with a POST connection once the connection string is created.
  2. Cookie: NPrinting uses Cookies for handling the Web security. You can find the Cookie information from the HTTP response of the authentication request (/login/ntlm). However you need to manually parse the useful part from the raw response, and apply it as the Cookie in the consequent requests. The example QlikView script showed this process.
  3. WITH CONNECTION: I use WITH CONNECTION syntax from REST connector to reuse a POST or GET connection.
  4. Looping: For polling the task execution status, I use a loop using "Do ... Loop". Pay attention that you want to drop both the master table and data table within one iteration, so the next iteration can get refreshed data value. I use "IF... THEN" to break the loop because I want to keep the last data table so that the user can have some information about the execution left in the data model. I also use a counter to control the loop because I don't want to wait forever during the debug.


The screenshots below show an example of creating a POST connection for authentication in Qlik REST connector.

RESTConfig1.JPG


Download the attached QlikView document and reload it from your QlikView server machine to test how it works.


At last, you may want to create a reload task in QlikView QMC and chain it to the reload task of your data application, so that the NPrinting publish task will be triggered automatically after the QlikView data reload task is completed successfully. You can find the settings from the screenshot below, or get help from this community article.

QMC_TaskChain.JPG


Thanks for your reading!



Comments
bc-thebruuu
Creator
Creator

Excellent work!

Did I already said it? LOL

Yang_Jiao
Support
Support

The same concept can be applied in Qlik Sense as well, by creating chained tasks.

kfoudhaily
Partner - Creator III
Partner - Creator III

hello,

I have worked on the same issue in march using NPrinting 18

How to use Qlik NPrinting APIs inside a Qlik View load script

0 Likes
bc-thebruuu
Creator
Creator

@kh fou: According to tests we did with Yang, if the NPrinting server is not located in the same machine of the QV Server, your example would not work, as prerequisite 5 is not fulfilled and origin keyword is not included into your header

0 Likes
kfoudhaily
Partner - Creator III
Partner - Creator III

it's true that I have only tested it where qlikview end nprinting server are running on the same server but it's working very fine to me.

regards,

jsobrinho
Creator
Creator

@bc-thebruuu 

Hi, 

About your post, how can solve this? My nprinting server is a different server from Qlik, what and where I need to put some information? It's my first time using qlik rest connector and npriting

0 Likes
Version history
Last update:
‎2022-09-21 05:11 PM
Updated by: