Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
pentaxadmin
Partner - Creator
Partner - Creator

Mashup-API bookmark,sheet navigation

Dear community:

I am having hard time to figure out what I am doing wrong and need some help. I am trying to do the following

1. Select Value from Field1 (Dropdown)

2. Select Value from Field2 (Dropdown)

3. Click the Button ('#enter_btn')

3. Based on the selection go to Sheet(SheetID field or variable vSheetID (whatever works better)

4. Based on the selection apply bookmark from BookmarkID field or variable vBookmarkID (whatever works better)

5. Display selected URL string (with variables for Bookmark and Sheet) in the <iframe>

Here is my JS:

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

     qlik.setOnError( function ( error ){

     alert( error.message );

     });

var app = qlik.openApp('<my app ID>', config);

// Clean any filters ----------

app.unlockAll();

app.clearAll();

// QVObjects ----------

app.getObject('kpi1','Field1');  // First Dropdown Selection qvo

app.getObject('kpi1','Field2'); // Second Dropdown Selection qvo

// Button ----------

$("#enter_btn").click(function() {

     app.model.waitForOpen.promise.then( function () {

     app.unlockAll();   //to unlock any previously locked values

     });

});

// Button ----------

$(function(){

        $('#enter_btn').click(function(){

            if(!$('#iframe').length) {

                    $('#iframeHolder').html('<iframe id="iframe" src="https://<server_name>/sense/app/<my app ID>"></iframe>');

            }

        });

     });

  });

Everything up to this point works as intended. I make a selection, click the button, app will open in the iframe, but I am not able to apply bookmark or selected state and navigate to the specific sheet in my iframe based on the selection.

Any guidance is greatly appreciated. I tried  app.bookmark.apply, app.variable.getContent, app.createCube Methods, but not able to make it work. I can't figure out how to feed the bookmark and sheetId into my iframe src string?

Thanks,B

1 Solution

Accepted Solutions
pentaxadmin
Partner - Creator
Partner - Creator
Author

OK. I think, I figure out what was causing the error. After removing if(!$('#iframe').length) { } Statement and keeping

$('#iframeHolder').html('<iframe id="iframe" src="' + sheet + '"></iframe>'); the sheet and bookmark got applied as intended and the button action navigates to appropriate sheet and applies bookmark.


Any suggestions on how to achieve the results are welcome. I am trying to learn JS/QS API - it took me a while, but I learned a lot by T/E. Definitely, console.log and debugger helped a lot to better understand the steps in JS.

.....

if(!$('#iframe').length) {

$('#iframeHolder').html('<iframe id="iframe" src="' + sheet + '"></iframe>');

}

View solution in original post

2 Replies
pentaxadmin
Partner - Creator
Partner - Creator
Author

I was able to move forward using app.createCube Method, and everything works as intended, except for when I try to change reportName - Bookmark will get updated, but sheet won't. Therefore my button, won't execute as intended. Any idea what I am missing in my JS? Just to mention dims (SheetID and BookmarkID are loaded as * INLINE statement in my script for each reportName)

.....

app.createCube({

qDimensions : [{

qDef : {

qFieldDefs : ["SheetID"]

}

}, {

qDef : {

qFieldDefs : ["BookmarkID"]

}

}],

qMeasures : [{

qDef : {

qDef : "1"

}

}],

qInitialDataFetch : [{

qTop : 0,

qLeft : 0,

qHeight : 20,

qWidth : 3

}]

},



function(reply){

$('#enter_btn').click(function(){

var sheet ="";

$.each(reply.qHyperCube.qDataPages[0].qMatrix, function(key, value) {

sheet += 'https://<server_name>/sense/app/<my app ID>/sheet/' + value[0].qText;

});

if(!$('#iframe').length) {

$('#iframeHolder').html('<iframe id="iframe" src="' + sheet + '"></iframe>');

}

var bookmark ="";

$.each(reply.qHyperCube.qDataPages[0].qMatrix, function(key, value) {

bookmark += value[1].qText;

});

app.bookmark.apply(bookmark);

        });

console.log(reply);

    }


);


pentaxadmin
Partner - Creator
Partner - Creator
Author

OK. I think, I figure out what was causing the error. After removing if(!$('#iframe').length) { } Statement and keeping

$('#iframeHolder').html('<iframe id="iframe" src="' + sheet + '"></iframe>'); the sheet and bookmark got applied as intended and the button action navigates to appropriate sheet and applies bookmark.


Any suggestions on how to achieve the results are welcome. I am trying to learn JS/QS API - it took me a while, but I learned a lot by T/E. Definitely, console.log and debugger helped a lot to better understand the steps in JS.

.....

if(!$('#iframe').length) {

$('#iframeHolder').html('<iframe id="iframe" src="' + sheet + '"></iframe>');

}