One of the most popular new features in Qlik Sense is snapshots and storytelling. When you discover something interesting in your Qlik Sense app you can take a snapshot of a visualization, including its selections and data, and then build a story where you use it. And you can recreate the selections from the snapshot and drill deeper into your data or look at it from another angle.
In many cases this works automatically for your extension too, but sometimes it doesn’t. In recent versions of Qlik Sense new features, like printing and export to PDF are also built on the snapshot feature, which makes it even more important for it to work. So here is a description of how it works and what you need to do to make your extension work in snapshots.
How does snapshots work?
You create a snapshot by clicking the camera icon in the visualization context menu. Qlik Sense will then make a copy of the data used for the rendering, known as the layout. This structure is then included in a new bookmark, that is created in Qix engine. Note that it’s not the HTML that is saved, nor is it a bitmap of the actual visualization on the screen. It’s the data.
So when the user wants to look at the snapshot, the data is loaded from the bookmark, Qlik Sense then checks what extension was used to visualize it, loads the extension, creates an object using the visualization, and calls the paint method of the visualization. But the layout parameter will not contain live data from the current selection state, it will contain data from the snapshot.
What this means for your extension
For snapshots to work your extension should use only the layout when rendering. You should not try to use the capabilities APIs to access data dynamically. Most likely it will not work, and if you manage to get it working, the data you get will be live and not reflect the state when the snapshot was taken. So make sure you add the data you need to the properties structure instead.
Also you need to keep the layout clean. It is good practice to treat it as read-only, adding nice-to-have references make make it impossible to serialize the layout, and creating the snapshot might fail.
And don’t forget to test creating snapshots from your extensions. Also verify that printing and exporting to PDF works, very likely your users expect them to.
4 thoughts on “Snapshots and Extensions in Qlik Sense”
What if no dimensions or measures are required for the extension to work? Is there a way to get the selections which were made when the snapshot was created? (e.g. Field: Region Name:, Value: APAC)
For this to work you need to add a qSelectionObject(http://help.qlik.com/en-US/sense-developer/September2017/Subsystems/EngineAPI/Content/GenericObject/LayoutLevel/SelectionObject.htm) to your layout, easiest by adding it to initialProperties.
I have built a filter pane container extension that holds different filter panes within it. Users can add objects into the container via the property panel, selecting from a list of master objects. These objects are then moved using the app.getObject method. Currently these objects appear in stories but do not appear when exporting to PDF. Am I right in thinking I’ll need to include the data definition for any objects that are to be added to the container for these to display on the PDF? Or do you think this could be down to another issue?
Thanks for all the content on this site, have used a lot!!
Hi Graham,I don’t think there is any way to make this work in PDF export, since getObject is not available. And while it might work in a story, the filter panes would probably show the current state of the app, not the one at the time of the snapshot. Hope that’s what you want.
Comments are closed.