Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
After upgrading our QAP server to the September 2017 release (and even after applying Patch 1 and Patch 2), I am receiving errors in my mashup, while the copy on the pre-September 2017 release works fine.
The error is "TypeError; Cannot read property 'applyBookmark' of undefined'. At first I though that this was due to the app.bookmark.apply method returning asynchronously, so I used $.when().done, but I still receive the error. Any ideas?
var strBookMark= strPageURL.substring(9,strPageURL.length);
console.log('strBookmark',strBookMark);
console.log('app=',app);
var promiseBookMark = app.bookmark.apply( strBookMark );
$.when(promiseBookMark).done(
function(strSuccess)
{
console.log('strSuccess',strSuccess);
Hi,
Perhaps app.model.waitForOpen.then( or app.model.waitForOpen.promise.then( would work?
Erik
Have you reported that to Qlik support? Sounds like a bug.
Erik Wetterberg
Hi rbartley,
It looks to me like the app model hasn't been loaded yet, try:
app.waitForOpen.promise.then(()=>{
//[....]
app.bookmark.apply( strBookMark );
//[...]
});
Yes, Erik is right, it looks like a bug, we will investigate.
I hope this helps.
aiham
Hi Aiham,
Thanks for your reply. I added the code in your snippet, but this also generates an error:
Cannot read property 'then' of undefined, but I can see that the app has been defined when I write it out to the console and the model appears to have been loaded too.
Richard
Hi Erik,
Thanks for your reply. This seems rather odd. I have responded to Aiham's reply below which, unfortunately, hasn't resolved the issue.
Richard
Hi,
Perhaps app.model.waitForOpen.then( or app.model.waitForOpen.promise.then( would work?
Erik
Hi Erik,
Bingo! The second option worked:
app.model.waitForOpen.promise.then(()=>{....}
Any idea why this might be behaving in a different way from all previous versions? Is it pure coincidence that I haven't encountered this before or is it likely that the model has changed with the new releases?
Regards,
Richard
Hi,
It's a bug, some change somewhere has broken this and nobody has noticed before release.
Are you applying a bookmark programatically immediately when then app is opened? If this happened when a user clicked something you would probably have to be fast to reproduce the error.
Erik Wetterberg
Ok, thanks once again.
I'm allowing users to save URLs which contain the bookmark id, e.g .......?bookmark=b27fe925-267e-4e1e-a55c-98eea4c83063, and then each time the page is opened I check for a bookmark in the URL and, if found, apply it.
In fact, I noticed that the version of IE we have installed does not seem to recognise the ES6 arrow function, so replaced
app.model.waitForOpen.promise.then(()=>{....});
with
app.model.waitForOpen.promise.then(function(){...});
Here's a link to some information on arrow functions in case anyone finds it useful.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions