Looking for something in google apps script that does something similar to ES6 javascript.
Ss.main.getRange('C2').setValue('${Ss.main.getRange(2,2).getDisplayValue()}')
expected C2 cell to equal the value in B2. instead i get ${Ss.main.getRange(2,2).getDisplayValue()}
Looking for something in google apps script that does something similar to ES6 javascript.
Ss.main.getRange('C2').setValue('${Ss.main.getRange(2,2).getDisplayValue()}')
expected C2 cell to equal the value in B2. instead i get ${Ss.main.getRange(2,2).getDisplayValue()}
- Although I'm not sure whether I could correctly understand about your question, do you want to copy the value of "B2" to "C2" using Google Apps Script? – Tanaike Commented Apr 12, 2019 at 0:53
2 Answers
Reset to default 5Look at there: V8 Runtime Overview
Example:
// V8 runtime
var name = `Hi ${first} ${last}.`;
var url = `http://localhost:3000/api/messages/${id}`;
The current version of Apps Script does not support ES6 string literals (but that will change with the uping V8 upgrade, hopefully in the near future). In the meantime, you can leverage the Utilities.formatString()
function.
Your sample code can be converted as follows:
Ss.main.getRange('C2').setValue(Utilities.formatString(
"%s",
Ss.main.getRange(2,2).getDisplayValue()
));
However, if all you need to do is convert the returned value to a string then you can use the getDisplayValue()
call directly (since the function returns a string by default):
Ss.main.getRange('C2').setValue(Ss.main.getRange(2,2).getDisplayValue());