Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Nicole-Smith

Automatic duplication/rename of Qlik Sense QVF on a schedule

I have a Qlik Sense QVF file with a daily reload task.  On the 2nd of the month, I need to keep a snapshot of the dashboard.

Manual process: On the 2nd of the month, I duplicate the QVF file, append the name of the month to the name of the dashboard, and publish it to the same stream as the original.  

Is there a way to automate this process?  

Labels (1)
1 Solution

Accepted Solutions
Levi_Turner
Employee
Employee

This can be done using the Repository API with Qlik-Cli for Windows (https://github.com/ahaydon/Qlik-Cli-Windows) being an easy wrapper.

I am using this as a code-base:

$dayOfMonth = '18' # Target Date of the Month
$appId = '5e34dbc8-bc07-4377-906d-bb370853d731' # Target App's ID
$month = (Get-Date).Month # Get the Month, will be numeric, e.g. 6
$monthName = (Get-Culture).DateTimeFormat.GetMonthName($month) # Get the MonthName localized to the user, e.g. June
if ((Get-Date).day -eq $dayOfMonth) {
    Connect-Qlik | Out-Null # Connect to Qlik Sense
    $app = Get-QlikApp -id $appId # Get the Target App's record
    Copy-QlikApp -id $app.id -name "$($app.name) $monthName" | Publish-QlikApp -stream $app.stream.id | Out-Null
}

this nets me this output:

2020-06-18 11_05_44-Apps - QMC.png

 

The example can of course be adapted to your day of the month. I'm just using today's date as a test case. The finalized script can then be saved to the server and run on a scheduled basis using Windows Task Scheduler (https://github.com/levi-turner/1400da7e-fbda-4a02-aa84-a63209c2aa02#config-steps-for-script for a pointer on scheduling PowerShell scripts as Windows Scheduled tasks)

 

Hope that helps

View solution in original post

6 Replies
Levi_Turner
Employee
Employee

This can be done using the Repository API with Qlik-Cli for Windows (https://github.com/ahaydon/Qlik-Cli-Windows) being an easy wrapper.

I am using this as a code-base:

$dayOfMonth = '18' # Target Date of the Month
$appId = '5e34dbc8-bc07-4377-906d-bb370853d731' # Target App's ID
$month = (Get-Date).Month # Get the Month, will be numeric, e.g. 6
$monthName = (Get-Culture).DateTimeFormat.GetMonthName($month) # Get the MonthName localized to the user, e.g. June
if ((Get-Date).day -eq $dayOfMonth) {
    Connect-Qlik | Out-Null # Connect to Qlik Sense
    $app = Get-QlikApp -id $appId # Get the Target App's record
    Copy-QlikApp -id $app.id -name "$($app.name) $monthName" | Publish-QlikApp -stream $app.stream.id | Out-Null
}

this nets me this output:

2020-06-18 11_05_44-Apps - QMC.png

 

The example can of course be adapted to your day of the month. I'm just using today's date as a test case. The finalized script can then be saved to the server and run on a scheduled basis using Windows Task Scheduler (https://github.com/levi-turner/1400da7e-fbda-4a02-aa84-a63209c2aa02#config-steps-for-script for a pointer on scheduling PowerShell scripts as Windows Scheduled tasks)

 

Hope that helps

Nicole-Smith
Author

Our production server consists of 4 servers--2 central and 2 rim.  Does the PowerShell script need to go on a specific one?  Or will it work on any of them?

Levi_Turner
Employee
Employee

Any will work (just like the QMC works across them all). But it'd be ideal to go against one of the back-end nodes, personally. This is backend activity so isolating it is ideal.

Manish_Kumar_
Creator
Creator

Hi @Levi_Turner 

Your Solution is pretty interesting!! And what is understand is

1. First we make a powershell file ,which created copy of qlik sense file with specific name.

2.Then to trigger this powershell file .. windows task scheduler is being used as per the requirement..Great!! 

My Use Case is what if I dont want to use Task Scheduler and I want that as soon as app refreshes its copy should be created ...

So Is there any way we can trigger .ps file from Qlik Sense backend ..like we execute batch files

Manish Kumar, Senior Business Analyst
Levi_Turner
Employee
Employee

The answer is yes, but how easy it is depends on the version of Qlik Sense Enterprise Client Managed. The technique here is use of External Program Tasks which are another task type (Reload Task, User Synchronization Tasks, External Program Tasks, (Hybrid) Distribution Tasks). Improvements were made in May 2021 (ref https://help.qlik.com/en-US/sense-admin/August2022/Content/Sense_Helpsites/WhatsNew/What-is-new-May2...) which exposed these task types as first class citizens in the QMC, prior versions required API work to create / edit them. The task itself will look something like this:

Levi_Turner_0-1662656211295.png

 

Where the path is C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (the path to PowerShell) and the parameters are what you want to pass to the executable. In my case, I want to bypass the execution policy which is enforced by IT and execute a script on a network path so I have something like this:  -ExecutionPolicy Bypass \\<myServer>\Data\activeDirectory\qlikADDepartment.ps1

On the trigger I have on successful completion of a task which is relevant to the script like so:

Levi_Turner_1-1662656303319.png

If you're not on May 2021, I'd consider whether you can upgrade because interacting with this API is annoying to be honest. It's do-able but I'd classify it as an advanced API 🙂 

 

Manish_Kumar_
Creator
Creator

Hi @Levi_Turner 

Would surely upgrade to May 2021 if it is feasible for my organization!!

But as a Developer my Concern was to sought out this API working on my own! So what i am asking for is-

The Qlik Cli module can be installed, and code that you have provided will perfectly serve my purpose with lil bit of adjustments,Now I want to just run this code ,So my question is

How to trigger a ps1 file from qlik sense scripting part (as we do for cmd batch files- can we trigger it in similar way..if yes then how!)

Not Sure why you are saying that this API is complex,as where i am stuck is stated above ..which i think has no complexity part !

Please correct if i am wrong anywhere!

Manish Kumar, Senior Business Analyst