1 Reply Latest reply: Apr 30, 2015 3:38 AM by Jérémy George RSS

    Get value of QV variable to use in JavaScript

    Thorsten Schröder

      Hello everyone,

       

      how can I get the value of a single variable and use it in Javascript?

      I need to get the current selection of a field from a variable and use this value as a string in order to do a if/else comparison.

       

      Example:

      varQV = Only(Field)

       

      In JS I then want to do: if (varQV ="string of varQV") ....

       

      I tried with the mydoc.GetAllVariables function but I can't get the string of the field only the definition [Only(Field)]

       

      Hope you can help.

       

      Thank you,

      Thorsten

        • Re: Get value of QV variable to use in JavaScript
          Jérémy George

          Unfortunately it is not possible to get the evaluation of a variable using the GetAllVariables function, only the definition is available in the returned object.

           

          However you can get the evaluation of the variable by using it in a Text expression of your extension property. In your definition.xml file, add :

          <Text Expression="=varQV" />

           

          You will then be able to get the variable value in your javascript code with the following code in your extension method:

           

          var varQV = this.Layout.Text0.text;