I want to execute a script as soon as I apply a filter to my Sheet. I can't find any event in the App script Docs that will allow me to do this, no onFilter event or anything obvious anyway. Does anyone know if this is possible, and if so, how to do it?
Google Sheets Appscript on apply filter event
google sheetsgoogle-apps-scriptgoogle-apps-script-triggers
Related Topic
- Google-sheets – How to automatically refresh a filter view in Google Sheets when new data comes in via Google Forms
- Google-sheets – Add a script trigger to Google Sheet that will work in Android mobile app
- Google-sheets – Sending formulas with Google Forms
- Google-sheets – Possible to perform an “undo” via app script
- Google-sheets – Automatically apply new formatting and remove time from a dynamically added Date-Time in google sheets
- Google-sheets – Create named Versions of Google Sheets (or other documents) automatically on a schedule
Best Answer
There is no simple trigger that runs when a filter is applied, but you can use an installable trigger to detect that. You can test an installable "on change" trigger like this:
To make the code run when the spreadsheet is changed, click the clock icon 🕓 in script editor, click +Add trigger and choose Select event type > On change > Save.
Note that the trigger will run every time any change is made to the spreadsheet. You will have to carefully examine the event object and the values returned by the various SpreadsheetApp.getActive* methods to determine whether you want your script to do its thing when it gets run through the trigger. When the event is related to filters, the
changeType
property of the event object will beOTHER
.