How to Make Reports Selectable with NPrinting On-Demand
We suggest that you do the How to Use NPrinting On-Demand to Set Recipients in Tasks before starting this tutorial.
This tutorial shows how to create a QlikView document that enables users to select the reports to generate via NPrinting On-Demand.
The steps will be:
Load the list of available reports into the QlikView document and display it
Add an NPrinting Report Extension that reads the selected report and and uses it to request the report from the server. To achieve this, we’ll add a QlikView formula to the NPrinting Report Extension that retrieves the name of the selected report.
This tutorial also explains how to use formulas inside NPrinting Extension objects to make them dynamic and reduce maintenance.
Attention: remember to save QlikView documents used as NPrinting connections with WebView mode deactivated. NPrinting cannot open QlikView documents with WebView mode activated because it doesn't have full control of QlikView functionalities.
Add Code to Script
Open the SalesDemo for Ajax.qvw QlikView document C:\NPrintingTraining\QlikViewDocuments\
Open the script editor (CTRL+E)
Enter the following code to generate a list of available reports:
LOAD * INLINE [
Excel Report Top 25 Products
PowerPoint Report with Multiple Pages - Current Selections
Word Report with Table of Contents
This adds three reports. We suggest copying the report names from NPrinting and pasting them into the script because they must be exactly the same.
Run a reload (CTRL+R), save the QlikView document and close the script editor
Turn Off WebView
De-activate WebView (View -> Turn on/off WebView) if active.
Add List Box to Sheet
Add a new sheet object to let users select a report to generate
Right click List Box object
Select New Sheet Object and click on list box
Set Field to ReportID
Put a check mark in the Always One Selected Value box so that only one ReportID can be selected to be sent to the NPrinting Server
Enter Select the report you want to preview in the Caption field
Click on the OK button
Re-activate WebView (View -> Turn on/off WebView)
Configure On-Demand Service Connection
Add an NPrinting Report Extension
Right click on the sheet
Select New Sheet Object
Go to Extension Objects menu
Drag and drop a new NPrinting Report object onto the sheet
Right click on the object
Click on Button appearance
Text: enter the QlikView formula ='Preview '& getfieldselections(ReportID,',',1) & ' report'. The button will display the selected report's name
Text Color: enter the QlikView formula =White()
Button Color: enter the QlikView formula =rgb(66,80,80)
Configure On-Demand Service Connection
On-Demand Service Connection
Hostname: localhost. Of course you can use a variable here also and use it in all objects so that when the server name changes you need to change only one variable value
HTTP Port: 9001
Configure Report Settings
Friendly name: enter the QlikView formula =GetFieldSelections(ReportID,',',1). In the NPrinting Queue button you’ll see only the report ID
NPrinting Project path: C:\NPrintingTraining\NPrintingFiles\OnDemand.nsq. QlikView formulas are also supported here
Report ID: enter the QlikView formula =GetFieldSelections(ReportID,',',1)
Connection ID: Sales Demo
Output format: PDF
Close the Properties window
Formulas can be used in all NPrinting Extension Object fields having the “fx” on the right side
Save the QlikView document
Demand Report Generation
Select Word Report with Table of Contents in the list box
Click on the Demand button
Demand Second Report Generation
Without waiting for the first report to finish being generated, select the report Excel Report Top 25 Products
Click on the request button.
Reports Are Ready
NPrinting Server will create the two reports sequentially and you can open them when they are ready. Click directly on the Reports queue (2) button.