I have a custom function using DeveloperMetadata
from other sheets in the workbook. The issue I have is that if I e.g. delete one of previous sheets (thus removing that metadata) the cell value doesn't change. The only trigger which recalculates this function is to make a simple whitespace change in the Script Editor and save the file.
Is there a method in Google Sheets to do this refresh automatically?
function get_prev_days(rest_key) {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheets = spreadsheet.getSheets();
var sheet_index = SpreadsheetApp.getActiveSheet().getIndex();
var value = 0;
for (var i = 0; i < sheet_index; i++) {
var meta = sheets[i].getDeveloperMetadata();
for (var j = 0; j < meta.length; j++) {
if (rest_key == meta[j].getKey()) {
value += Number(meta[j].getValue());
}
}
}
return value;
}