Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
This article explains how to move an app using Dynamic Views to a QAP environment, where it's not possible to edit the app directly from the hub.
Environments:
When a Dynamic View App is moved, the ODAG link and selection app link need to be recreated. This can be performed with the following API calls.
#Create new ODAG link
$newTemplateApp='88ab115f-6df0-4c3e-82d8-47304f56c9e1'
$newSelectionApp='ba9eddfe-b912-425e-91bb-4b7b3b0e4a83'
$body = '{"id":"","name":"NewODAGLink","templateApp":"'+$newTemplateApp+'","rowEstExpr":"1",
"privileges":[],"rowEstExpr":"count(Expression1)","properties":{"rowEstRange":[{"context":"*","highBound":700}]},"dynamicView":true,
"selectionApp":"'+$newSelectionApp+'"}'
$hdrs = @{}
$hdrs.Add("hdr-usr","DOMAIN\Administrator")
$url = "https://qlikserver2.domain.local/hdr/api/odag/v1/links"
$resp = Invoke-RestMethod -Uri $url -Method Post -Headers $hdrs -Body $body -ContentType 'application/json'
$resp.objectDef.id
#Create selection app link usage
$body = '{"linkList":["'+$resp.objectDef.id+'"]}'
$hdrs = @{}
$hdrs.Add("hdr-usr","DOMAIN\Administrator")
$url = "https://qlikserver2.domain.local/hdr/api/odag/v1/apps/"+$newSelectionApp+"/selAppLinkUsages?type=view&includeCharts=true"
Invoke-RestMethod -Uri $url -Method Post -Headers $hdrs -Body $body -ContentType 'application/json'
In the above example, 88ab115f-6df0-4c3e-82d8-47304f56c9e1 is the new App ID for the template app after importing it in the new environment, ba9eddfe-b912-425e-91bb-4b7b3b0e4a83 is the new App ID for the selection app.
It will first create a new ODAG link, then use the ODAG link ID returned to create the Selection App link usage.
For simplicity, the above example is using header authentication to call the API, you may need to adapt the authentication method based on your environment, see here for more details.
The next thing that needs to be done is to use the Engine API SetProperties() method to update the OdagLinkRef in the dynamicappview and "app" and "viewId" properties for the dynamic chart (container).
Those two actions will need to be repeated for each Dynamic View object that has been added to the app.
If you are running a version of Qlik Sense that still has the Engine API Explorer available, you can run the actions from there, otherwise you will have to write your own code calling the Qlik Engine API to perform the actions.
Open dynamicappview object:
{
"handle": 1,
"method": "GetObject",
"params": {
"qId": "adChWz"
}
}
SetProperties:
{
"handle": 2,
"method": "SetProperties",
"params": {
"qProp": {
"qInfo": {
"qId": "adChWz",
"qType": "dynamicappview"
},
"qExtendsId": "",
"qMetaDef": {
"odagLinkRef": "43749a24-d0ac-4a96-8836-960696fca5fd",
"timestamp": 1610982015455
},
"qStateName": ""
}
}
}
OdagLinkRef needs to match the new ODAG Link UI created in PowerShell in the previous step.
Open Dynamic Chart (container object)
{
"handle": 1,
"method": "GetObject",
"params": {
"qId": "dpuxYJ"
}
}
SetProperties:
{
"jsonrpc": "2.0",
"id": 5,
"result": {
"qProp": {
"qInfo": {
"qId": "dpuxYJ",
"qType": "container"
},
"qExtendsId": "",
"qMetaDef": {},
"qStateName": "",
"children": [
{
"externalReference": {
"masterId": "29506988-f6ef-4873-845d-6a99a454f5bc",
"app": "88ab115f-6df0-4c3e-82d8-47304f56c9e1",
"viewId": "43749a24-d0ac-4a96-8836-960696fca5fd"
},
"label": "DVTest",
"refId": "RAxNp",
"type": "externalChild"
}
],
"showTitles": false,
"title": "",
"subtitle": "",
"footnote": "",
"disableNavMenu": false,
"showDetails": false,
"borders": "auto",
"showTabs": false,
"useDropdown": true,
"useScrollButton": true,
"showIcons": false,
"visualization": "container",
"qChildListDef": {
"qData": {
"visualization": "/visualization",
"containerChildId": "/containerChildId",
"qExtendsId": "/qExtendsId",
"title": "/title",
"showCondition": "/showCondition"
}
},
"supportRefresh": true,
"hasExternalChildren": true
}
}
}
In the externalReference section, "app" must be the new Template App ID and "ViewId" must be the new ODAG link ID.
Object IDs inside apps don't change when moved from one environment to antoher.
In order to check the Object IDs from the UI on a Qlik Sense Enterprise Environment with access to the hub, add /options/developer to the URL, then select the developer menu on the right for the dynamicappview object ID and right-click the dynamic chart and choose "developer" in order to get the ID for the dynamic chart
You can use the mashup build by @AlexPolorotov to perform all above actions from a user interface instead of having to perform the API calls yourself.
I wasn't able to find the ID of the 'dynamicappview' object as per the guide so I had to resort to querying the app for all objects of such type via Engine API Explorer.
{
"handle": 1,
"method": "GetObjects",
"params": {
"qOptions": {
"qTypes": [
"dynamicappview"
],
"qIncludeSessionObjects": false,
"qData": {}
}
}
}