I've a spreadsheet that uses a function from another external script (
I think at some point google is not allowing this other external script to run, any ideas how can i make sure how to run this other script?
Also any improvements on my code will be welcomed as i never did anything on google spreadsheets.
Appreciated!
CodePudding user response:
Instead of trying to read the result of custom function from the spreadsheet, call the custom function as a "normal" function.
function snapshot(){
const spreadsheet = SpreadsheetApp.getActiveSpreadshet();
var Carteiras = spreadsheet.getSheetByName('Carteiras');
const values = Carteiras.getRange("C2:C23").getValues();
const balance = values.map(row => {
const ticker = 'a-ticker'; // or use row[some-index-1] or other way to get the ticker
const address = 'a-address'; // or use row[some-index-2] or other way to get the address
const refresh_cell = null; // not needed in this context
return [CRYPTOBALANCE(ticker,address, refresh_cell)]
});
Carteiras.getRange("D2:D23").setValues(balance);
}
The above because Google Apps Script officials docs have not disclosed how exactly the formula recalculation works when the spreadsheet is opened by the script when the spreadsheet has not been first opened by the active user as usually occurs when a daily time-driven trigger is executed. I guess that the custom functions are loaded into the active spreadsheet function list when the formula recalculation is triggered by Google Sheets web client-side code.
Related