0
votes

I'm getting an error "This operation is not supported on a range with a filtered out row." on Google Apps Script while trying to retrieve the filter. (I'm attempting to implement a solution I found here (Adding a row to a filtered range).

The error:

This operation is not supported on a range with a filtered out row.
    at getFilter(functions:190)
    at editHousehold(Code:51)
    at addHousehold(Code:30)

Where the function getFilter row 190 is the following:

var filter = sheet.getFilter();

"sheet" is a Sheet object parameter sent by editHousehold(51) - that line is:

var oldCrit = getFilter(SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Household List"), true);

I'm actually implementing this to avoid the error in question - why would I be receiving it when I'm simply trying to access the sheet's filter??

1

1 Answers

0
votes

The thing is that you can not insert a new row inside a filtered sheet, because there isn't a method to add new row or setValues on a Filter class.

getFilter() returns an object of the Filter class that does not have a method as setValue() which you can use on your editHousehold function.

getRange() returns an object of the Range class, which has as methods as setValue() that you can use to edit a value within a range.

So, the question is:

Are you sure that the 'Sheet' object that you are trying to edit on editHousehold function is really of Sheet class and not of Filter class?

Behind remains the following question:

Are you sure the class object that you are accessing in any of the functions have the methods you are trying to apply?

To answer this questions check on the documentation provided for each class and see the methods allowed.

Hopefully this will solve your question, if not, please provide the content of the said functions to be able to debug them properly.