I have a Google Appscript that has been running perfectly for some years. The script sums cells based on the background colour of the cell.
For a while now some cells error on the computation with no changes on the code. Since yesterday, all the calls seem to error.
The error is: TypeError: Cannot read properties of undefined (reading 'm_getMessage__java_lang_String') (line 71).
And line 71 is: var ranges = spreadsheet.getRangeList(srange).getRanges();
, where srange is a var srange = ["X15:X", "Y15:Y"];
.
After some debugging, I am experiencing a strange behaviour where the getRanges() method sometimes returns an Array, and sometimes a variable of type Proxy, which seems to point to a Java ArrayList. This menas that the .length is not available (though .size() seems to work). I couldn’t find what makes it return different elements (without changing the code).
It also does not behave as it used to when the range specified to getRangeList
is a single range (in a list).
2