Answer the question
In order to leave comments, you need to log in
How to recalculate formulas on demand?
There is a table, a script is written for it. The data changes periodically and is stored in the cache. The cells have various data, using the formula get('id1'), get('id2') ... and so on. There is a request and getting data from the cache. Data may change and must be updated. Is there a way to recalculate the data for example by executing a function??? is it possible to recalculate all the formulas on the sheet that can change their position?
Answer the question
In order to leave comments, you need to log in
No. All formulas participate in the same event loop.
You can only force a complete recalculation of the entire Table by calling SpreadsheetApp.flush()
. There will be no sense
in custom formulas . flush
Set-operators do not work in these formulas either.
Using CacheService is of little use
Translated the entire script into a digestible form and made a small example of how such a function works
/**
* @OnlyCurrentDoc
*/
/**
*
* The TESTCACHESERVICE function
*
* @param {param} param
* @return {number}
* @customfunction
*/
function TESTCACHESERVICE(param) {
const cache = CacheService.getScriptCache();
const cached = param === 'break' ? 0 : +cache.get('cached') + 1 || 0;
cache.put('cached', cached);
return cached;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question