Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I use Qlik CLI to duplicate apps, publish and create tasks. This is all going well. However, I now need to adjust reload tasks. The apps first had to be reloaded after app A was successfully completed. Now the apps need to be reloaded after app B is finished successfully.
In the Qlik CLI package I can only find the command "Add-QlikTrigger". I don't see any commands like "Get-QlikTrigger", "Remove-QlikTrigger" or "Update-QlikTrigger".
Do I have to delete and recreate the entire task and then provide it with the desired trigger?
For example this task :
Get-QlikReloadTask -Id 87a8cfe5-cc28-4035-8a3f-bd0277523866 -raw
id : 87a8cfe5-cc28-4035-8a3f-bd0277523866
createdDate : 2022-04-11T12:28:25.777Z
modifiedDate : 2022-11-23T08:24:04.759Z
modifiedByUserName : XXX
customProperties : {}
app : @{id=5b58c51d-e23a-4f6d-aa16-1c62136ad661; name=Commission Statement; appId=; publishTime=2023-01-17T20:00:56.931Z;
published=True; stream=; savedInProductVersion=12.1219.3; migrationHash=21ecc792c56e18162f1785d3d41f28fdaced5c96; availabilityStatus=0; privileges=}
isManuallyTriggered : False
operational : @{id=482640a1-2bd7-49f5-af0a-5a62f3a81a2f; lastExecutionResult=; nextExecution=1753-01-01T00:00:00.000Z; privileges=}
isPartialReload : False
name : Automated reload of app Commission Statement
taskType : 0
enabled : True
taskSessionTimeout : 30
maxRetries : 0
tags : {@{id=6a516ce1-7279-467d-82f7-bd9afda95dfd; name=Sales; privileges=}}
privileges :
schemaPath : ReloadTask
How can I retrieve and manage the active trigger of this task?
The Following PowerShell Function is built using QlikSenseCLI (not the same as the Qlik-CLI-Windows)
The function requires a SourceAppID and a DestinationAppID and will copy all reaload tasks & triggers from one app to another
From this function you would be able to see that we can call the function (Get-QSSchemaevent -Full -Filter "ReloadTask.id eq $($ReloadTask.Id)") to get the "Triggers" for the reload tasks.
(Update-QSSchemaEvent) can be used to update modified triggers.
##Update Trigger
$SchemaEvent = Get-QSSchemaevent -Id f8bf1d52-d17e-4a54-9b29-c5c3ab67714e
#Modify the Event as required
$SchemaEvent.Name = "Updated_$($SchemaEvent.Name)"
$SchemaEvent.Enabled = $false
Update-QSSchemaevent -Id $SchemaEvent.Id -SchemaEventObj $SchemaEvent
function Copy-QSReloadTasks {
param
(
[Parameter(Mandatory = $true)]
$SourceAppID,
[Parameter(Mandatory = $true)]
$DestinationAppID
)
#Get the Condensed Verion of the Reload Task
$AppReloadTasks = Get-QSReloadtask -Filter "App.id eq $($SourceAppID)"
foreach ($ReloadTask in $AppReloadTasks) {
#Get the full version
$ReloadTaskFull = Get-QSReloadtask -Id $ReloadTask.Id
#Get the Schema Events for the Reload Task
$SchemaEvents = Get-QSSchemaevent -Full -Filter "ReloadTask.id eq $($ReloadTask.Id)"
#Get Destination App Condensed, Filter alway returns a Array so select first
$DestinationApp = $(Get-QSApp -Filter "id eq $($DestinationAppID)") | Select-Object -First 1
#Create a New Reload task, clearing the ID,Operational and relacing the App
## You can further manipulate the Name etc here if needed.
$NewRT = New-QSReloadTask -InputObject $ReloadTaskFull -Id ([guid]::Empty) -App $DestinationApp -Operational $Null
#Add the New reload task to QlikSense
$DestRTFull = Add-QSReloadtask -ReloadTaskObj $NewRT
#Get New ReloadTask Condensed, Filter alway returns a Array so select first
$DestRT = $(Get-QSReloadtask -Filter "id eq $($DestRTFull.id)") | Select-Object -First 1
foreach ($Event in $SchemaEvents) {
#Create a New Schema Event, clearing the ID,Operational and relacing the ReloadTask
## You can further manipulate the Name etc here if needed.
$NewQSSchemaEvent = New-QSSchemaEvent -InputObject $Event -Id ([guid]::Empty) -Operational $null -ReloadTask $DestRT
#Add the schema event to the reload task
$QSSchemaEvent = Add-QSSchemaevent -SchemaEventObj $NewQSSchemaEvent
}
}
}
this can then be called like to, where we call the function and supply the required ID's
Connect-QlikSense -TrustAllCertificates
Copy-QSReloadTasks -SourceAppID b73ad8a5-ad67-4778-b350-8151976895bf -DestinationAppID ac2a350a-b54e-460f-9c67-c0d4eb5bea73
or like so, where we use a UI to select the Source and Destination Apps from a grid view and pass the IDs to the function
Connect-QlikSense -TrustAllCertificates
$Apps = Get-QSApp
#create a formattedlist to make the UI a little more readable
$FormattedApplist = $($Apps|Select-Object -Property Name,ID,@{Name="Stream";e={$_.Stream.Name}})
$SelectedApp = $FormattedApplist|Out-GridView -OutputMode Single -Title "Copy Reload Tasks from"
$DestinationApp = $FormattedApplist|Out-GridView -OutputMode Single -Title "Copy Reload Tasks to"
Copy-QSReloadTasks -SourceAppID $SelectedApp.Id -DestinationAppID $DestinationApp.Id