NPrinting API – Qlik Rest SubRoutines v1.2

Hi All,

This is just urgent update of NPrinting.qvs library to allow for its usage with NPrinting February 2020 SR1. This version of NPrinting returns from API response cookie with additional string which needs to be handled differently when creating vCookie variable. The below change is incorporated in library and requires one more parameter to work: vNPVersion variable. This is a variable which value you need to update accordingly to your version and it simply represents year-month-sr version. So for February 2020 SR1 you need to set it to 20200201, where meaning of digits is: 2020 – year, 02 – feb, 01 – SR1.

Below code is added in library to handle rest of it.

 
//  NPrinting version (this is to maintain one library and support for release changes)
//  version (as of now 27 Mar 2020 there is only change prior Feb 2020SR1 and after)
  
     Let vNPVersion    =   '20200201';    // Meaning of digits: 2020 - year, 02 - feb, 01 - SR1
     ...
     ...

// Cookie version
     If $(vNPVersion) < 20200201 Then
        Trace Loading cookie based on NPrinting version prior Feb 2020 SR1 release;
        Let vCookie 	= TextBetween('$(vCookieRaw)','Secure,','Path=/',2);
     Else
        Trace Loading cookie based on NPrinting version equal or post Feb 2020 SR1 release;
        Let vCookie 	= TextBetween('$(vCookieRaw)','SameSite=None,','Path=/',2);
     EndIf
     ;

cheers

Lech

16 Comments

  1. Lech, how could we amend the task call to just grab all executions? We were considering trying to use the NPrinting API to send Failed or warning task statuses to our Microsoft Teams alerts. We are using this for Qlik Sense and it works well.

    Like

    1. Hi Roostor,
      When you say “to just grab all executions” what do you mean? Do you want all executions ever done for all tasks, or something like get all Tasks in Admin console and the latest executions for all of them? What would be the final expected result? Something like 1 table with 3-4 columns like: App Name–>Task Name–> Last execution status-> Last updated?

      My Subroutines dont have scenario where you would get all information at once. Since you need to pass appid to get task ids and task ids to get execution details I assume It would be a nested loop like the dummy concept below

      For each vAppId
      Get Task Ids List
      For Each vTaskId
      Get ExecutionsIds
      For Each vExecutionId
      GetExecutionDetails
      Next
      Next
      Next

      My current code would need to be adjusted to allow you to do that.

      Like

  2. Hi Lech

    Great library! I hope this product gets more attention in the future.

    Is there a way to get a list of the single reports generated in one task? For now I think we dont get the reports that failed inside a task.
    If you have generated 100 reports it is very time consuming to check the failed ones in the Log section of the Task execution.
    Did you came across such an use case?

    Best regards
    Hatus

    Like

    1. Hi Hatus,
      Library is still work in progress, and there are improvements coming in filter creation section

      Regarding your question:
      API does not allow you to get single report execution details. It only allows you to get high level task execution details and as you know 1 task can actually contain 100s reports.

      So log section will still give you a lot more info and details than api.

      And no-the purpose of library was not monitoring but rather task and error handling

      Like

  3. Hello,
    with June 2020 relase I have to change it again
    Let vCookie = TextBetween(‘$(vCookieRaw)’,’SameSite=None,’,’Path=/’,3);

    Regards

    Like

    1. Hi Gianfranco, thanks for this information. At present I am not having a working environment running on June 2020, so I cannot comment on this. I will however work on that as soon as I can.

      Like

    1. Hi Gianfranco – Correct, this seems like rest connector issue. I am aware that Qlik is working on fix. At this stage there is nothing we can do other than wait for next patch/release, check release notes and see if something was changed in rest connector. I presume the earliest it will be in Sep 2020

      Like

  4. For some reason when I post my tasks / id / executions

    The task runs multiple times in my Nprinting server? and I get two to three emails regarding that task… is it sending the command multiple times?

    Like

  5. Hi Trevor – it is hard to tell what you are doing without seeing your script, data model after run and executions… Subroutines are written to cycle through available tasks…based on criteria set in parameters. It may be that more than one task meets this criteria (has similar or the same name) or….. I saw also scenario where Qlik Sense engine was unsuccessful running whole task and retried few times… This should not happen in normal stable environment, but I have seen it happening and confirmed by looking at engine logs.

    Like

    1. Thanks Lech,

      My data model shows only one entry in my “Executions” table; and I have modified your subroutine to only have the one static ID of the task I want to run. It is very strange.

      My API POST to the reload metadata for one ID only runs once; confirmed in the Tasks log in NPrint; but the publish task Execution triggers it multiple times (always 2/3). There are no loops in my script; and no for…each statements.

      Is there anything else I should look at?

      Like

      1. Is there a chance you are using the “stupid” Data Manager or clicking through it accidentally? Data Manager happens to actually run scripts in the background (i guess for data profiling purposes) which may be the reason of multiple triggers… Or as I mentioned before – issues with engine..

        Like

  6. Lech, that is exactly what was happening-I knew that it ran the script again also… I just didn’t fathom that it would also run the POST again.

    Like

    1. I added a variable to check the lastReload time of the App; and not run the POST parts of the script if it had been reloaded within the last x minutes; solving the issues with Data Manager re-running the data.

      Like

      1. There you go… Data Manager in my opinion is the most idiotic feature which I cannot disable in any possible way in Qlik Sense. It is annoying and anyone who has little bit of Qlik scripting knowledge stays away from it as it can only mess up with your scripts. Time wasting feature but also very unpredictable: Imagine if your script were actually having some serious POST methods which could mess up transactions or something…
        Anyway – I wish there was a toggle to disable it or hide it all together

        Like

Leave a comment