Skip to main content

Deployment & Management

Discussion board where members learn more about Qlik Sense Installation, Deployment and Management.

Announcements
Welcome to Qlik Community! Check out our new navigation! FIND OUT MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Seed1
Contributor III
Contributor III

Qlik CLI Reload Automation script

Hi, I'm attempting to create a Powershell script to search for all Apps that have CustomProperty = 'RequestReload', then find a Task that exists for that App, trigger it and remove the CustomProperty. I would then run this as a scheduled task every 5 mins. Users have access to set the custom property.

This has been suggested a solution to another question where i can't use the Reload button extension without giving access to the dataconnections. It sounds like a good solution, i've managed to install Qlik Cli and use it. But i'm fairly new to PowerShell, everything i put together is from snippets from the web and I can't find many examples of Qlik Cli commands or scripts.

So far I have:

Get-QlikApp -filter "customProperties.value eq 'RequestReload'" | foreach {Get-QlikReloadTask -Filter "eq $_.app.Id" | Start-QlikTask -Wait | Wait-QlikExecution}

The 'Get-QlikReloadTask' part of this simply isn't right. Pulling this out separately I get errors when trying to return the app.id

Sorry to reach out, i've been trying to figure this one out for days - I have tried! Any guidance would be appreciated.

Labels (5)
2 Solutions

Accepted Solutions
andoryuu
Creator III
Creator III

Sounds like a great suggestion 🙂

I've adjusted and tested on my side. Please note I'm recommending you add the name of your custom property as well incase in the future you have other custom properties that have similar values (in this case probably unlikely, but code reuse is hugely important)
Get-QlikApp -filter "customProperties.definition.name eq 'Whatever' and customProperties.value eq 'RequestReload'" | ForEach-Object {Get-QlikReloadTask -Filter ("app.id eq {0}" -f $_.id) | Start-QlikTask -Wait | Wait-QlikExecution}

View solution in original post

Seed1
Contributor III
Contributor III
Author

Thanks Andoryuu, you've been a great help with this query. Works brillianty. I've added the second section to change the CustomProperty and prevent continuous reloading.

 

Get-QlikApp -filter "customProperties.definition.name eq 'ReloadRequest' and customProperties.value eq 'Request'" `

    | ForEach-Object {Get-QlikReloadTask -Filter ("app.id eq {0}" -f $_.id) `

        | Start-QlikTask}

 

Get-QlikApp -filter "customProperties.definition.name eq 'ReloadRequest' and customProperties.value eq 'Request'" `

    | ForEach-Object {Update-QlikApp -id $_.id -customProperties ReloadRequest='Requested'}

View solution in original post

8 Replies
andoryuu
Creator III
Creator III

Sounds like a great suggestion 🙂

I've adjusted and tested on my side. Please note I'm recommending you add the name of your custom property as well incase in the future you have other custom properties that have similar values (in this case probably unlikely, but code reuse is hugely important)
Get-QlikApp -filter "customProperties.definition.name eq 'Whatever' and customProperties.value eq 'RequestReload'" | ForEach-Object {Get-QlikReloadTask -Filter ("app.id eq {0}" -f $_.id) | Start-QlikTask -Wait | Wait-QlikExecution}
Seed1
Contributor III
Contributor III
Author

Thanks Andoryuu, you've been a great help with this query. Works brillianty. I've added the second section to change the CustomProperty and prevent continuous reloading.

 

Get-QlikApp -filter "customProperties.definition.name eq 'ReloadRequest' and customProperties.value eq 'Request'" `

    | ForEach-Object {Get-QlikReloadTask -Filter ("app.id eq {0}" -f $_.id) `

        | Start-QlikTask}

 

Get-QlikApp -filter "customProperties.definition.name eq 'ReloadRequest' and customProperties.value eq 'Request'" `

    | ForEach-Object {Update-QlikApp -id $_.id -customProperties ReloadRequest='Requested'}

andoryuu
Creator III
Creator III

@Seed1  glad it's working out.  If you want to expand this further you can remove the custom property from the app when you are done.  It's a matter of getting the app into a variable, removing the custom property, and using Invoke-QlikPut to push the JSON of the app back to the server.  It'll take you some time to work out (Invoke-QlikPut is a helper function, not first line - and updating apps isn't always easy with Qlik-CLI, but we do it all day every day).  Our entire deployment process is automated using this and custom properties that get set by users and automatically updated as apps are moved around.  Saves BOATLOADS of admin time.

Seed1
Contributor III
Contributor III
Author

Hi everyone, just a quick follow up on this one as i found that users with Analyser licenses cannot adjust the app properties full stop. I have gotten around this by bolting on a PS script onto the one just completed to read the AppID from a text file and trigger a reload from that. Separately users now have access to a batch file that prompts them to enter the App ID or URL (copied from their browser) - this is then added to the text file  which the PS script reads every minute.

Server side Powershell:

Get-Content \\myserver\QlikReloadList\QlikReloadList.txt | ForEach-Object {Get-QlikReloadTask -Filter ("app.id eq {0}" -f ($_ -replace '.*/')) -ErrorAction SilentlyContinue | Start-QlikTask -ErrorAction SilentlyContinue}

Clear-Content \\myserver\QlikReloadList\QlikReloadList.txt

 

Client side batch (could easily be PS instead, i just had a menu batch script out there already that i added this to):

cls
set /P App="Enter Qlik App Address or Code: "
@Echo %App% >> \\myserver\QlikReloadList\QlikReloadList.txt
cls
Echo Following Qlik apps have been instructed to Reload Data. Please allow time for this to complete.
Echo.
more \\myserver\QlikReloadList\QlikReloadList.txt
Echo.
Pause

Seed1
Contributor III
Contributor III
Author

Small tweak: i found that if there is more than one reload task then this triggers them all at once which then fail all at once. Added 'Select-Object -first 1' to prevent this and choose the first task every time instead.

 

Get-QlikApp -filter "customProperties.definition.name eq 'ReloadRequest' and customProperties.value eq 'Request'" `
| ForEach-Object {Get-QlikReloadTask -Filter ("app.id eq {0}" -f $_.id) `
| Select-Object -first 1 `
| Start-QlikTask}

Shubham_Deshmukh
Specialist
Specialist

Hi @Seed1 , @andoryuu ,

Qlikerm, can u please help me for implementing the same ? 
Wondering through some documents for this, facing so much of chaos , as I dont have much idea about powersehll.

Please Guide.

Shubham

Seed1
Contributor III
Contributor III
Author

Hi Shubham,
It took me a lot of time to figure this out, hopefully I can help. You want users to be able to reload published apps without them having access to the load script or QMC? Do you want both analyser and professional licence holders to be able to do this or just professional?
qlkksfkin
Contributor
Contributor

Was there more here?  I am also looking to do the same thing for our end users.  They will be Analyzers and I'm trying to figure out how to pass a date parameter to filter the load scripts? 
Pointing me in the right direction would be extremely appreciated :0)

Thank you,