I use the following function to refresh basic filters (filtering and sorting) after my data changes:
function refreshDashboardFilter() {
let {
basicFilter
} = Sheets.Spreadsheets.get(spreadsheetID, {
ranges: ["Dashboard"],
fields: "sheets(basicFilter)"
}).sheets[0];
if (basicFilter) {
Sheets.Spreadsheets.batchUpdate({
requests: [{
setBasicFilter: {
filter: basicFilter
}
}]
}, spreadsheetID);
}
}
Is it possible to refresh a filter view as well in a similar way? Probably, use the same function for both.
As another approach, in order to refresh both the basic filter and the filter view, I think that it can be achieved by 2 API calls. The modified script is as follows.
Modified script:
sheetNamesare refreshed by 2 API calls.References: