I have the below script which is intended to automatically filter the active sheet:
function setFilter() { var ss = SpreadsheetApp.getActiveSpreadsh