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: 
warfollowmy_ver
Creator III
Creator III

How get current value from object-extension

How to get the current state of a document variable value from object-extension?

I already see solutions more than once as in the topic below. But none of this works. Everyone writes about the same thing. But there is not a single working file xml or js.

Get value of QV variable to use in JavaScript

Step 1 in .xml     <Text Expression="=varQV" />

Step 2 in .js      var varQV = this.Layout.Text0.text;

Now I use the construction below. But the value of the variable is visible only inside the function.

This is an elementary task and I do not know how to solve it ... I need help. Give please work files for analysis.

Qv.AddExtension('YourExtension', function () {

    var CurrentDocument = Qv.GetCurrentDocument();

 

          CurrentDocument.GetAllVariables(function (vars) {

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

              if (vars.name === "your_var") {

                    your_var= vars.value;

                    break;

                    };

              alert(your_var); //your_var

              }

    });


    alert(your_var); //undifined

});

1 Solution

Accepted Solutions
warfollowmy_ver
Creator III
Creator III
Author

Everything works, just needed to re-create the extension.

Definition.xml:

<?xml version="1.0" encoding="utf-8"?>

<ExtensionObject

Path="ImagesView"

Type="object"

  Label="ImagesView"

  Description="ImagesView">

<Text Label="Text" Type="text" Expression="=var_img"/>

</ExtensionObject>

Script.js:

Qv.AddExtension('ImagesView', function () {

alert(this.Layout.Text0.text.toString());

});

View solution in original post

1 Reply
warfollowmy_ver
Creator III
Creator III
Author

Everything works, just needed to re-create the extension.

Definition.xml:

<?xml version="1.0" encoding="utf-8"?>

<ExtensionObject

Path="ImagesView"

Type="object"

  Label="ImagesView"

  Description="ImagesView">

<Text Label="Text" Type="text" Expression="=var_img"/>

</ExtensionObject>

Script.js:

Qv.AddExtension('ImagesView', function () {

alert(this.Layout.Text0.text.toString());

});