Qlik Community

Qlik NPrinting Discussions

Discussion Board for collaboration on Qlik NPrinting.

Highlighted
mredeker
New Contributor

NPrinting REST API and OnDemandRequestFilters

All,

I am using the NPrinting REST API to trigger OnDemandReport generation with subsequent download of the generated report file into my Java application. So far all works fine

Since we have a multi tenant application each tenant is supposed to only see his data. For this I created a global filter and attached that to the NPrinting report. Using the API I can change the filter field value and the report is created correct for the appropriate tenant

I was wondering if this is a thread safe solution? What if 2 tenants request the same report at the same time and my code is changing the global filter. Is the last one the winner and both clients would receive the report with the same data?

So I was thinking that I don't attach the filter directly to the report but use the OnDemandRequestFilters when triggering the OnDemandReportRequest. Unfortunately I don't find any documentation about this. The API reference only states that there is an object called OnDemandRequestFilters but with no further information.What is the documented "initialBookmark" supposed to be? Is that a filter Id? Do you have any code samples for the REST API and how to use the OnDemandRequestFilters?

Thanks,

-Marcus

6 Replies
Employee
Employee

Re: NPrinting REST API and OnDemandRequestFilters

Hi,

Each single request is isolated so each will be processed with its filters. This answer is based on the way of work of Qlik NPrinting. Qlik NPrinting can manage multiple requests at the same time, the Scheduler coordinates the work among Engines.

So In my opinion you don't risk to have two requests with different filters that come back with the same data.

I'm sorry but I don't have code samples on this topic more than what you can see in the help site.

Best Regards,

Ruggero

---------------------------------------------

When applicable please mark the appropriate replies as CORRECT https://community.qlik.com/docs/DOC-14806. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads as HELPFUL if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads as HELPFUL if you feel additional info is useful to others.



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
mredeker
New Contributor

Re: NPrinting REST API and OnDemandRequestFilters

Since I only have one filter and I am using the REST API to change this filters field value, it could be that my 2 threads each change the value and then I call the REST API for the OnDemandReportRequest. In this case both report generations use the filter field value from the last change.

I was able to stop my to threads right before I call the OnDemandRequest and was able to verify that both reports are identical. This would be a show stopper for this scenario Of course I could synchronize the calls to the REST API which would be not so nice.

So I need to create a new filter for each request and attach it to the OnDemandRequest which brings me back to my second part of the question, how are OnDemandRequestFilters used??

Regards,

-Marcus

ter
New Contributor

Re: NPrinting REST API and OnDemandRequestFilters

You will have a problem trying to modify the filter and requesting two reports at the same time. You are right, it is not thread safe.

You have many solution:

Use JWT to authenticate your user and have Section Access or User filters in place.

Use OnDemandRequestFilters AdditionalFilters to specify the GUID of the Filters to apply  (so in theory you can have one filter per tenant and use its ID to identify the filter).

mredeker
New Contributor

Re: NPrinting REST API and OnDemandRequestFilters

Thanks, Tommaso, for the confirmation

It sounds like you used the OnDemandRequestFilters JSON object already.

Do you have any code snippet for me?

Regards,

-Marcus

Partner
Partner

Re: NPrinting REST API and OnDemandRequestFilters

Hi All,

Has anyone used OnDemandRequestFilters JSON object? I tried multiple ways:

  1. {\"filters\": { \"additionalFilters\" : [ { \"ColumnName: value\" } ] } }
  2. {\"filters\" : { \"additionalFilters\" : [ { \"ColumnName\": \"value\" } ] } }    with this syntax request is getting failed.
  3. {\"filters\" : { \"additionalFilters\" : [ {\"Nprinting filter ID\" } ] } }       filter ID like "xxxxxxxx-a922-4135-aaad-xxxxxxxx"

but nothing works. looking forward for help from the experts.

Additional Info: we are trying to implement on-demand report generation from mashup portal in .net code. I am able to create the session and on-demand request, report is also getting generated (downloading all data) but we are stuck at passing filter value(s). I tried to pass the filter value selected in mashup using "selections" property but that didn't worked after that trying to use "filters" that is also not working.

Please let me know if any more details required.

Regards,

Tauceef

 

Employee
Employee

Re: NPrinting REST API and OnDemandRequestFilters



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.