I'm using Google Apps Script to change the background colors of certain rows of cells in a Google Sheet. For some reason, when I run them as a function of a range of cells (not that I have tried otherwise), setBackgroundColor('white') works, while setBackgroundColorTransparent() invokes a "TypeError: not a function" message. Am I missing some bit with the usage or syntax of setBackgroundColorTransparent()?
My code:
function colorSundays() {
var maxColumns = sheet.getMaxColumns();
for (i = 1; i <= 31; i++) {
var currentCell = sheet.getRange(i, 1);
var value = currentCell.getValues();
if (value == 'Sunday') {
var currentRow = sheet.getRange(i, 1, 1, maxColumns);
currentRow.setBackgroundColor('#F87CF8');
} else {
var currentRow = sheet.getRange(i, 1, 1, maxColumns);
// currentRow.setBackgroundColor('white');
currentRow.setBackgroundColorTransparent(); // Preferred, but now working right now.
}
}
}
The error message:
[20-06-08 19:09:04:246 CDT] TypeError: currentRow.setBackgroundColorTransparent is not a function
at colorSundays(Code:52:18)
at setThisMonth(Code:61:3)