In sheets apps script, unable to fetch correct cell contents in filtered view

60 Views Asked by At

I have a very simple sheet – 10 columns by 80 rows, no hidden rows/columns.
I have a simple filter over the entire spreadsheet allowing me to sort on any column.
Once sorted, the row # shown in my filtered view is of course not the same as the unfiltered row #.
The data shown in each cell in the filtered view is from the unfiltered view as it should be.
So somewhere there is a mapping of my filtered rows to the unfiltered rows.
Let’s say row 15 in the filter/sorted view is mapped to row 21 in the unfiltered view.
I have an onSelectionChange script that gets invoke when I select a cell on the filter/sorted view.
Let’s say I select E15 (ie column 5, row 15).
Using getActiveCell() it shows row 15 and column 5. That’s correct.
Using getValue(), it returns the value in the unfiltered view from row 15, not the unfiltered mapped row 21.
The value I see in my script from getValue() does not match the value seen in the filtered/sorted spreadsheet.
How can I retrieve the value from the mapped cloud row?

0

There are 0 best solutions below