Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
We have a multi-tenanted environment and need to start customer tasks on a daily basis. By way of an example, we have 33 customers that each have their own reload task. The data is extracted from a customer's onsite source on a daily basis and loaded into a multi-tenanted Data Warehouse.
The Qlik Sense tasks run based on a daily schedule at 8 am each morning, this is not ideal as the Qlik Sense tasks do not know when the Data Warehouse has finished loading. Ideally, I would like to trigger each task via the QRS API once the DWH has completed.
Each customer reload task has been a tagged with the source system the data relates to, for example, the 33 customers have a tag of "HPOS" against each reload task.
I would like to be able to use the QRS API to do two things:
1. Filter a list of reload tasks based on a tag, in the above example "HPOS".
2. Start the reload tasks based on the filtered list.
Any suggestions are welcome.
I would suggest that you explore the Qlik CLI (GitHub - ahaydon/Qlik-Cli: Qlik Sense Cmdlet for PowerShell) which allows you to utilize the Qlik Sense Repository Service (QRS) APIs through PowerShell.
Get-QlikTask -full returns a list of all tasks, including the tag values.
Get-QlikTask -full | where {$_.tags.name -eq "HPOS"}) pipes the task list into a filter, to only keep the required tags.
(Get-QlikTask -full | where {$_.tags.name -eq "HPOS"}).id limits the filtered task list to only the task ID values.
(Get-QlikTask -full | where {$_.tags.name -eq "HPOS"}).id | foreach { Start-QlikTask $_ } as a final step pipes each filtered task ID to being started.
Hello,
Is it possible to filter the list of reload tasks based on a specific pattern on the name ? Let's say, the tasks that the name contains a specific caracteres exmpl : Names contains "test" ?
If so, please let me know how to implement such a thing ..
@k21 have a look at the Relational operators section at the documentation page
In your case you can filter the tasks by using:
name -so "test"
this will filter all entities that are having test in their name
Stefan
Okay, thanks for ur quick reply,
and is it possible to extract the id of this task, using qlik qrs options ? I was testing this:
Probably check the content of the TaskNameDependency variable? or the context is wrong and such tasks do not exists on the cluster you are quering?
The same command returns the task ids for me.
Stefan
Finally it is working, Thanks a lottttttttttt!
I still have one qst;
I m creating a task_2 that depends from other task_1 but task_2 is being created but it does not include the trigger in qlik UI, how to fix this, any ideas plz ?
Possible to share some code?
Stefan
Sorry for the late response, It takes me a bit of time to figure this out .. I think i am able now to create tasks that depend from other tasks .. I created a composite rule :
compositeRule=${compositeRule::-1}
compositeEvent='{"timeConstraint":{"days":0,"hours":0,"minutes":360,"seconds":0},"compositeRules":['$compositeRule'],"name":"EventTrig","enabled":true,"eventType":1}'
and then I am using a post curl api to create the task with this compositeRule ..
curl -X POST "$serverUrl/create?xrfkey=$id" \
-H "x-qlik-xrfkey: $id" \
-H "Content-type: application/json" \
-H "Authorization: Bearer ${token}" \
-d '{"task": { "app": { "id": "'$idapplication'" }, "enabled": true , "schemaPath": "ReloadTask" , "name": "'"$TaskName"'"}, "compositeEvents": ['$compositeEvent'] }'
Now I am struggling to create a compositeRule for a Daily and weekly tasks .. I think I should be able to create a curl post command with a different composite, but i am not able to define the compositeRule for daily or weekly tasks .. I hope it is clear ..
This is my curl post:
response=$( curl -X POST "$serverUrl/create?xrfkey=$id" \
-H "x-qlik-xrfkey: $id" \
-H "Content-type: application/json" \
-H "Authorization: Bearer ${token}" \
-d '{"task": { "app": { "id": "'$idapplication'" }, "enabled": true , "schemaPath": "ReloadTask" , "name": "'"$TaskName"'" }, "schemaEvents":[{ "name": "'$TaskFrequence'" ,"enabled":true, "eventType":0, "timeZone":"Europe/Paris","daylightSavingTime":0,"startDate": "'$startDate'","expirationDate":"9999-01-01T00:00:00.000", "schemaFilterDescription": ["'"$schemaFilterDescription"'"] , "incrementDescription": "'"$incrementDescription"'" , "incrementOption": "'$incrementOption'"}] }' )
I think I know what's the error, apprently it is related to my config, can anyone please check this for me ?