I found what I believe is a problem with createHidden().setValue().
I am using a hidden box to pass information to handler functions. When there is a & in the string an encoding is done while not expected – by me.
var test = '[[12060,"Crédit R&D à recevoir"]]';
var hidden = app.createHidden().setId('z').setName('z').setValue(test);
When I read the data back it’s
[[12060,"Crédit R&D à recevoir"]]
It’s basically causing problems later on with Utilities.jsonParse().
Now without the &
var test = '[[12060,"Crédit RD à recevoir"]]';
var hidden = app.createHidden().setId('z').setName('z').setValue(test);
When I read the data back it’s what I am expecting – meaning no encoding:
[[12060,"Crédit RD à recevoir"]]
Now if I do the same with app.createTextBox().setText(test); I do not have any encoding causing a problem even with the &. I will get back [[12060,"Crédit R&D à recevoir"]] with the & not encoded.
Is this a bug or a feature/behavior I am not aware of for the createHidden.setValue()?
Thanks if somebody can clarify for me this mystery that made me loose a good hour!
UPDATE : I reported the issue to Google and it’s officially a bug – see issue 1576.
Google accepted the issue as a new bug to be fixed – see issue 1576.
So in the meantime, we should use
createTextBox().setText()which do not have the HTML encoding problem.