Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Specialist
Specialist

Qlik Sense - Default App Bookmark in Mashup

Hi everyone,

 

I have created a bookmark in my app and set this  as the app default, so that it is applied when opening the app.  This works fine on the Qlik Sense server, but it is not applied when migrating the app to my QAP server and using it in a mashup, even though I can see that the bookmark has been migrated (by looking in the single configurator in the dev hub).  Could someone from Qlik please confirm this?

In the meantime, I have used the applyBookmark method.

Thanks in advance.

Richard

 

Labels (1)
7 Replies
Highlighted
Partner
Partner

Hi Richard,

I am also having the same problem.

Could you advise how you applied the applyBookmark method please?

@plu Are you able to shed some light on this please?

Thanks.

Highlighted
Employee
Employee

Hi Bev,

The bookmark is applied by the client when the app is opened. Not by the engine or the app itself. Therefore this feature is only available when using the app within the Qlik Sense Client. 

I'm no expert at the API, but examples on how to use the bookmark api is available at:

https://help.qlik.com/en-US/sense-developer/February2019/Subsystems/EngineAPI/Content/Sense_EngineAP...

 

Regards,

Patrik.

Highlighted
Specialist
Specialist

Hi Beverly,

Sorry for the delay, my account was de-activated by mistake. You should be able to create the bookmark in the app then use 

app.bookmark.apply(BookmarkId).

This works for me.

 

Highlighted
Partner
Partner

Hi could you please give an example for this ?

Highlighted
Specialist
Specialist

Hi,

The easiest way to show this is to create a new mashup in the dev-hub, choose Grid layout, choose an app from the drop-down list that has a bookmark in it, drag a visualization from the left-hand side and then go to the .js page and add app.bookmark.apply(<bookmark id here>) to the code that was automatically created.

Here's a snippet:

 

/*global require*/
/*
 * Bootstrap-based responsive mashup
 * @owner Erik Wetterberg (ewg)
 */
/*
 *    Fill in host and port for Qlik engine
 */
var prefix = window.location.pathname.substr( 0, window.location.pathname.toLowerCase().lastIndexOf( "/extensions" ) + 1 );

var config = {
	host: window.location.hostname,
	prefix: prefix,
	port: window.location.port,
	isSecure: window.location.protocol === "https:"
};
//to avoid errors in workbench: you can remove this when you have added an app
var app;
require.config( {
	baseUrl: (config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port : "" ) + config.prefix + "resources"
} );

require( ["js/qlik"], function ( qlik ) {

	$("#closeerr").on('click',function(){
		$("#errmsg").html("").parent().hide();
	});
	qlik.setOnError( function ( error ) {
		$("#errmsg").append("<div>"+error.message+"</div>").parent().show();
	} );

	//
	function AppUi ( app ) {
		var me = this;
		this.app = app;
		app.global.isPersonalMode( function ( reply ) {
			me.isPersonalMode = reply.qReturn;
		} );
		app.getAppLayout( function ( layout ) {
			$( "#title" ).html( layout.qTitle );
			$( "#title" ).attr("title", "Last reload:" + layout.qLastReloadTime.replace( /T/, ' ' ).replace( /Z/, ' ' ) );
			//TODO: bootstrap tooltip ??
		} );
		app.getList( 'SelectionObject', function ( reply ) {
			$( "[data-qcmd='back']" ).parent().toggleClass( 'disabled', reply.qSelectionObject.qBackCount < 1 );
			$( "[data-qcmd='forward']" ).parent().toggleClass( 'disabled', reply.qSelectionObject.qForwardCount < 1 );
		} );
		app.getList( "BookmarkList", function ( reply ) {
			var str = "";
			reply.qBookmarkList.qItems.forEach( function ( value ) {
				if ( value.qData.title ) {
					str += '<li><a href="#" data-id="' + value.qInfo.qId + '">' + value.qData.title + '</a></li>';
				}
			} );
			str += '<li><a href="#" data-cmd="create">Create</a></li>';
			$( '#qbmlist' ).html( str ).find( 'a' ).on( 'click', function () {
				var id = $( this ).data( 'id' );
				if ( id ) {
					app.bookmark.apply( id );
				} else {
					var cmd = $( this ).data( 'cmd' );
					if ( cmd === "create" ) {
						$('#createBmModal' ).modal();
					}
				}
			} );
		} );
		
	/***** THIS IS WHERE I INSERTED THE CALL TO ADD THE BOOKMARK *****************/	
		app.bookmark.apply('dabca368-8c46-4251-9726-0b60a0145f87');
		
		
		$( "[data-qcmd]" ).on( 'click', function () {
			var $element = $( this );
			switch ( $element.data( 'qcmd' ) ) {
				//app level commands
				case 'clearAll':
					app.clearAll();
					break;
				case 'back':
					app.back();
					break;
				case 'forward':
					app.forward();
					break;
				case 'lockAll':
					app.lockAll();
					break;
				case 'unlockAll':
					app.unlockAll();
					break;
				case 'createBm':
					var title = $("#bmtitle" ).val(), desc = $("#bmdesc" ).val();
					app.bookmark.create( title, desc );
					$('#createBmModal' ).modal('hide');
					break;
				case 'reload':
					if ( me.isPersonalMode ) {
						app.doReload().then( function () {
							app.doSave();
						} );
					} else {
						qlik.callRepository( '/qrs/app/' + app.id + '/reload', 'POST' ).success( function ( reply ) {
							//TODO:handle errors, remove alert
							alert( "App reloaded" );
						} );
					}
					break;
			}
		} );
	}
	//callbacks -- inserted here --
	//open apps -- inserted here --
	var app = qlik.openApp('1d0af2d7-a6df-422e-ae83-0249232759a6', config);


	//get objects -- inserted here --
	app.getObject('QV02','bbb31edd-f836-4bb1-a826-7a230d14f760');
	//create cubes and lists -- inserted here --
	if(app) {
		new AppUi( app );
	}

} );

 

 

 

 

 

Highlighted
Partner
Partner

Thanks

Highlighted
Specialist
Specialist

That's ok.  If it works for you, please use "Accept as a solution" so that others that come across this post will know it worked.