Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
our goal is to read all the variable defintions in a document. The Problem ist that only 2 variables are displayed in the extension.
If I have selected 3 individual variable definitions to display them, I get an error code 2. In the loop as shown in the sample below it display just 2 rows.
Can anyone help me to get all variable definitions in a exportable format!? It's very important for me and I am not find any solution.
Thanks in advance!
Best Rgds
Martin
Thats the sample code:
Qva.AddExtension('Konsolidierung', function(){
var obj = this.Element;
var doc = Qv.GetCurrentDocument();
var varsRetrieved = false;
doc.SetOnUpdateComplete(function(){
if(!varsRetrieved){
Qv.GetDocument("").GetAllVariables(function(variables){
for(var i = 0; i < variables.length; i++){
var a = variables.name + " = " + variables.value;
obj.innerHTML=a;
//var Konsolidierung = this.GetVariable();
//obj.getElementById("ptest").innerHTML = variables.name + " = " + variables.value;
//this.Element.appendChild(p);
//alert(variables.name + " = " + variables.value);
}});
varsRetrieved = true;
}
});
}, false);
Hi Martin,
this is what works for us:
---
(function() {
Qv.AddExtension('ReadVariables', function() {
console.log('ReadVariables eXtension loaded');
var height = this.GetHeight();
var width = this.GetWidth();
var container = $('<div />').css({
height: height,
width: width,
overflow: "auto"
}).appendTo($(this.Element).empty());
Qv.GetCurrentDocument().GetAllVariables(function(vars) {
$.each(vars, function(index, varObj) {
container.append($('<div>' + varObj.name + ' = ' + varObj.value + '</div>'));
});
});
});
})();
---
It's worth to mention that the callback function of GetAllVariables( ) runs asynchronous which gives a problem if you assign the values inside to an outer scope variable.
- Ralf