Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I have the following code:
app.variable.getByName('vPivotSorting').then(variableModel => {
variableModel.getLayout().then(variableLayout => {
console.log("variableLayout: " + JSON.stringify(variableLayout));
console.log(variableLayout.qString);
});
})
app.variable.setStringValue('vPivotString', 'dumbTest');
app.variable.getByName('vPivotSorting').then(variableModel => {
variableModel.getLayout().then(variableLayout => {
console.log("variableLayout: " + JSON.stringify(variableLayout));
console.log(variableLayout.qString);
app.variable.setStringValue('vPivotString', '2');
});
})
});
This is three 'sections' of code, the first gets the string value of a variable, and prints it to console.
The second bit sets the string value to 'dumbTest'
and the third prints it again.
The setStringValue method isn't working though, I can see no evidence it's been set, and it's not returning any errors.
I'm new to javascript, is there something I'm missing here?
thanks,
James.
To confirm, NO string is ever set it simply remains it's default which is set in the app script level.
Hi,
Not sure this helps, but you would need to wait for setStringValue:
app.variable.setStringValue('vPivotString', 'dumbTest').then(function(){
//get the variable value
});
Hi,
Not sure this helps, but you would need to wait for setStringValue:
app.variable.setStringValue('vPivotString', 'dumbTest').then(function(){
//get the variable value
});
Hi Erik thanks I see you answering a lot of questions.
I did suspect this was me not understanding the promises properly but think that makes sense.
I'll have a look at waiting for the response of the setStringValue.
Your other solutions aren't great for what I'm using this for, I'm trying to set a variable in the dashboard to change an expression in a chart, so it's already a bit of a bodge job
thanks anyway,
James.