Qlik Community

QlikView Extensions

Discussion Board for collaboration on QlikView Extensions.

Highlighted
warfollowmy_ver
Contributor 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

});

Tags (1)
1 Solution

Accepted Solutions
warfollowmy_ver
Contributor III

Re: How get current value from object-extension

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());

});

1 Reply
warfollowmy_ver
Contributor III

Re: How get current value from object-extension

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());

});