Interact with bookmarks
Note: Where possible, use qlik-embed and qlik-api rather than this framework. Please refer to this guide to learn how to manage bookmarks using qlik-embed.
Third-party cookies: This tutorial leverages cookies for auth, which are blocked by some browser vendors. Please use an OAuth solution where possible, which doesn’t leverage cookies.
In this tutorial, you are going to learn with sample code how to interact with
bookmarks through APIs using enigma.js
, by building a simple bookmark
manager.
If you’re just interested in the code produced in this tutorial, skip to the Summary section.
Prerequisites
General Qlik Sense knowledge about bookmarks and selections plus basic HTML and JavaScript experience would be preferable.
What you need:
- Node.js (version 12 or newer)
- A terminal (for example Git Bash on Windows, or Terminal.app on Mac)
- A modern web browser, for example Google Chrome
- A text editor or IDE of your choice, for example Visual Studio Code
- An existing web integration, or possibility to get one created in your tenant
Project structure and setup
For this project, you are going to use:
- enigma.js to communicate with the Qlik Associative Engine
- parceljs to start a development server and bundle the application
- bootstrap as a CSS framework
With your preferred terminal, create the project folder, initialize with npm init
,
and install the required dependencies:
# new folder to contain the project files:mkdir bookmark-managercd bookmark-manager
# initialize the project without having it ask any questions# this creates a `package.json` in the root of your directorynpm init -y
# install the required dependenciesnpm i -S enigma.jsnpm i -D parcel@next
In the scripts
property of the newly generated package.json
file, add a
new script entry allowing you to start a development server. Next, add a new property called
browserlist
for parceljs
to correctly set the browser configuration for the
app bundle (see parceljs#browserlist
for more details)
"scripts": { "start": "parcel index.html --open" }, "browserslist": [ "last 1 Chrome version" ],
- Create an
index.html
file using your favorite editor and save the file in the project folder.
<!DOCTYPE html><html> <head> <title>Bookmark Manager</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" /> <script type="text/javascript" src="app.js"></script> </head> <body> <div class="jumbotron text-center"> <h1>Bookmark Manager.</h1> <p>This a web app example showcasing bookmarks with enigma.js.</p> </div> <div class="container"> <table class="table"> <thead class="thead-dark"> <tr> <th scope="col">#</th> <th scope="col">title</th> <th scope="col">fields</th> <th scope="col">sheetId</th> <th scope="col">creationDate</th> <th scope="col">actions</th> </tr> </thead> <tbody></tbody> </table> </div> </body></html>