-
Re: How to use JS API in Extension
Kevin Hammer Mar 26, 2013 10:17 PM (in response to Kevin Hammer )I found this in another post and am able to get it to find the variables I need:
var doc = Qv.GetCurrentDocument(); var varsRetrieved = false; doc.SetOnUpdateComplete(function(){ if(!varsRetrieved){ Qv.GetDocument("").GetAllVariables(function(variables){ var varlist = ""; //Let pids = =concat(distinct [$(=$(%%v_SelectedKey($1)))], '$(%%v_SelValuesDelimiter)', [$(=$(%%v_SelectedKey($1)))]); for(var i = 0; i < variables.length; i++){ if (variables[i].name.indexOf("v_SelectedKeyValues") != -1) { varlist += variables[i].name + " = " + variables[i].value + "\n"; } } alert(varlist); //alert("pids" + " = " + pids + "\n" + varlist); }); varsRetrieved = true; } });
the problem that remains is that it doesn't give me a value, but an equation instead:
concat(distinct [$(=$(%%v_SelectedKey($1)))], '$(%%v_SelValuesDelimiter)', [$(=$(%%v_SelectedKey($1)))])
I need to know how to get the value of that equation in my extension script.
-
Re: How to use JS API in Extension
Daniel Rozental Mar 26, 2013 10:28 PM (in response to Kevin Hammer )Change your variable, add a "=" sign at the start, as the first character.
-
Re: How to use JS API in Extension
Kevin Hammer Mar 26, 2013 10:41 PM (in response to Daniel Rozental )I'm not sure what you mean. How would I, for example, get the value of a document variable named "%%v_SelString1" to display in an alert?
-
-
-
Re: How to use JS API in Extension
Kevin Hammer Mar 26, 2013 11:51 PM (in response to Kevin Hammer )I made some progress on this by adding a text field to the definition likes this:
<Text Initial="" Expression="=$(%%v_SelectedKeyValues(1))"/>
Turns out the "variable" I was after is actually a function, and i need to pass in an index value as a parameter.
I was able to print the value using this line in my extension script:
this.Layout.Text0.text
While thats good progress and i'm learning, I still haven't solved my problem. I need to get the value of %%v_SelectedKeyValues(n) from my extension script.
Thanks for the help so far!