Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!

Qlik Sense: Move an app with Dynamic Views to a QAP environment

100% helpful (1/1)
cancel
Showing results for 
Search instead for 
Did you mean: 
Damien_V
Support
Support

Qlik Sense: Move an app with Dynamic Views to a QAP environment

Last Update:

Mar 8, 2023 12:33:01 AM

Updated By:

Damien_V

Created date:

Jan 20, 2021 5:16:52 AM

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:

  • Qlik Sense Enterprise for Windows April 2020 and later
  • Qlik Analytics Platform for Windows April 2020 and later

 

Resolution

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 a new ODAG Link and Selection App link usage (PowerShell)
#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.

 

Update the objects properties for dynamicappview and dynamic chart

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.

 

Tips on how to find the Object IDs for the dynamicappview and the dynamic chart

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

Damien_Villaret_0-1611138884297.png

 

Damien_Villaret_1-1611138919559.pngDamien_Villaret_2-1611138953343.pngDamien_Villaret_3-1611139026711.png

 

Third-party tools to perform the actions from a User Interface

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.

https://apolorotov.medium.com/qlik-sense-move-an-app-with-dynamic-views-or-odag-to-a-qap-ad4544363c4...

 

Labels (1)
Comments
rshnaper
Contributor
Contributor

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": {}
}
}
}

 

Version history
Last update:
‎2023-03-08 12:33 AM
Updated by: