Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jesper_bagge
Contributor III
Contributor III

extract document name using QV JS API

I've been scouring the web for quite some time trying to find a method to grab the document name using the QV JS API.

I'm developing a document extension and could really use a more complete documentation than the official one found here: QlikView JavaScript API Reference - Version 11

Does anyone happen to know how to get the document name?

Cheers!

1 Solution

Accepted Solutions
jesper_bagge
Contributor III
Contributor III
Author

In the end I found two usable solutions, thanks to Firebug.

If you're interested, you can call either:

window.document.title or window.qva.View

to get some interesting values. However - neither of them works very well in web-view on local desktop.

View solution in original post

4 Replies
Not applicable

Hi Jesper,

1. Create a variable like 'DocName' in the application

2. Create a document event Trigger on 'onOpen'. Add the action 'Set variable', fill it with the name of the variable and for the value something like '=DocumentName()'

3. on the extension side in the file script.js, in the Qva.AddDocumentExtension function part,  add this code :

MyDoc = Qv.GetCurrentDocument();

MyDoc.GetAllVariables(function(vars) {

            for (var i = 0; i < vars.length; i++) {

                var obj = vars;

                if ( obj.name == 'DocName' ) {

                    // var text = obj.text;

                    MyDocumentName= obj.value;                  

                }

            }

        });

And you should get the name of the document in the MyDocumentName javascript object

Hope it's help !

jesper_bagge
Contributor III
Contributor III
Author

Hi Antoine,

Thanks! I've had that or a quite similar solution as my last resort, but it would be so much better if there was a standard way to get the application name through the API.

This solution requires a change to the QV datamodel (although a variable and a trigger is quite minimal...). I would like to have my document extension self-contained and deployable without changes to the target application.

Cheers!

Not applicable

Humm I see...

Does the name of your application is contained somewhere in the application (text object...) ?

If it's the case, you can use something like (in jquery) :

$('.myDiv').text();

.text() | jQuery API Documentation

jesper_bagge
Contributor III
Contributor III
Author

In the end I found two usable solutions, thanks to Firebug.

If you're interested, you can call either:

window.document.title or window.qva.View

to get some interesting values. However - neither of them works very well in web-view on local desktop.