Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
danelooman
New Contributor III

Extension disappearing after bookmark add

I am building an extension that allows users to generate links for their bookmarks. It works like a charm except if the user creates a new bookmark using the default way then my extension disappears. I assume it has to do with  layout.qBookmarkList.qItems but I am not sure. Anyone have any experience with this? 

1 Solution

Accepted Solutions
Highlighted
ErikWetterberg
Honored Contributor

Re: Extension disappearing after bookmark add

Try setting a breakpoint in the paint method. Then inspect the bookmarklist and look for any information that’s missing and that you need. Is everything really available in qMeta ? You could also try to let the debugger break on caught errors, since Qlik Sense catches all errors in extensions.

 

Hope this helps

View solution in original post

4 Replies
ErikWetterberg
Honored Contributor

Re: Extension disappearing after bookmark add

When you say disappear you medan it falls to render? And if you refresh the page its there again?

How do you get the bookmark list? By including it in initialProperties or with an API call? You probably need to debug and step through your code.

danelooman
New Contributor III

Re: Extension disappearing after bookmark add

I am getting the bookmarks by grabbing the layout from the paint function then sorting/looping through layout.qBookmarkList.qItems. It is very weird, if I delete the newly added bookmark the extensions renders again. Below is my full paint function if you need more info. Thank you for any help you can provide.  I should add that I don't get any console errors at any time. 

 

paint : function($element, layout) {
            $(document.body).find(".bootstrap_inside").remove();
            var html = '', app = qlik.currApp(this);
			var sheet = (qlik.navigation.getCurrentSheetId().sheetId);
			
            //adding bootstrap wrapper
            html += '<div class="bootstrap_inside bookmark_inside">';
                var html2 = '<p>Not all bookmarks will be shared.  To create a bookmark that can be visible by other teammates, you will need to use a special naming convention.  Bookmarks that have a title beginning with one of the following prefixes will be visible by other teammates.</p><p style="margin-top:8px;"><em><strong>Note:</strong> The prefixes are <strong>NOT</strong> case sensitive.</em></p></div>';
                html2 += '<div style="margin-top:8px;"><strong><ul><li>Z-PDV &nbsp;&nbsp;&nbsp; Z-MCH &nbsp;&nbsp;&nbsp;Z-MKT</li><li>Z-OPS &nbsp;&nbsp;&nbsp; Z-FIN &nbsp;&nbsp;&nbsp; Z-ECM</li></ul></strong>';
                //html += '<input type="text" id="BMInput" value="" placeholder="Enter Bookmark ID"/> <button class="daneBtn"id="applyBMButton">Apply</button>';
                html += '<ul class="mainnav"><li class="hassubs"><a>Select a Bookmark &#9662;</a><ul class="dropdown"><li class="subs hassubs">Personal Bookmarks &#9656;<ul class="dropdown">';
                
                //sorting bookmarks
                layout.qBookmarkList.qItems.sort(function(a,b) {
                var textA = a.qMeta.title.toUpperCase();
                var textB = b.qMeta.title.toUpperCase();
                return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
                });     
                            
                let ZTitleList = ["Z-PDV","Z-MCH","Z-FIN","Z-OPS","Z-ECM","Z-MKT"];
                
                //creates options for personal bookmarks
                layout.qBookmarkList.qItems.forEach( function(value)  {             
                    if((ZTitleList.indexOf(value.qMeta.title.toUpperCase().substring(0, 5)) <0)){                 
                        html += '<li class="subs"><a id="'+ value.qInfo.qId +'">' + value.qMeta.title + ' : ' + value.qMeta.owner.name.replace(/\s*\(.*?\)\s*/g, '').replace(" ", ", ") + '</a></li>';                  
                        } 
                    });
                html += '</ul></li>';
                
                //Uses ZTitles to create sub groups and selections of bookmarks
                ZTitleList.forEach( function(e){
                    html += ('<li class="subs hassubs">'+ e.substring(2) + ' Bookmarks &#9656;<ul class="dropdown">'); 
                    
                    layout.qBookmarkList.qItems.forEach( function(value) {
                        if( value.qMeta.title.toUpperCase().substring(0,5) == e ){
                            html+= ('<li class="subs"><button class="daneBtn" value="<a href="<a href="https://qlikdev.dcsg.com/sense/app/'+" target="_blank">https://qlikdev.dcsg.com/sense/app/'+</a>" target="_blank"><a href="https://qlikdev.dcsg.com/sense/app/'+</a" target="_blank">https://qlikdev.dcsg.com/sense/app/'+</a</a>> app.id + '/sheet/' + sheet + '/state/analysis/bookmark/' + value.qInfo.qId + '">Copy</button><a id="'+ value.qInfo.qId +'">&nbsp;'+ value.qMeta.title.substring(6) + ' : ' + value.qMeta.owner.name.replace(/\s*\(.*?\)\s*/g, '').replace(" ", ", ")  +'</a></li>');
                            }                   
                        });  
                    html+= ('</ul></li>');                  
                    });
                html += '</ul></li></ul>';              
                html += '</div>';
				$(document.body).find(".qv-object-Bookmarks-Dane").parent().parent().parent().parent().css("z-index","2147483629");

            $element.html(html2);
            $(document.body).find(".qs-toolbar__right").prepend(html);
            applyBookmark($element, layout, app);
            copyBookmark($element, layout, app);
            applyBookmarkInput($element, layout, app);
            return qlik.Promise.resolve();
}};});

 

 

Highlighted
ErikWetterberg
Honored Contributor

Re: Extension disappearing after bookmark add

Try setting a breakpoint in the paint method. Then inspect the bookmarklist and look for any information that’s missing and that you need. Is everything really available in qMeta ? You could also try to let the debugger break on caught errors, since Qlik Sense catches all errors in extensions.

 

Hope this helps

View solution in original post

danelooman
New Contributor III

Re: Extension disappearing after bookmark add

Thank you Erik. After checking the data closer like you suggested I found that the owner is not added to a created bookmark until later. I added some data validation for that field and it is right as rain. Thank you again.