Skip to content

About "Saving a history of muFunds data automatically" #87

@cidi69

Description

@cidi69

I did a small modifications on the code to allow saving the history of multiple funds.
The example code works only for one fund.

var ss = SpreadsheetApp.getActiveSpreadsheet();
var s1 = ss.getSheetByName(sheet1);
var s2 = ss.getSheetByName(sheet2);
var lastDate = s2.getRange(s2.getLastRow(), 1).getValue();

funds.forEach(function(fund) {
var date = s1.getRange(fund.dateCell).getValue();
var parsedDate = new Date(Date.parse(date));
// var lastDate = s2.getRange(s2.getLastRow(), 1).getValue();
// Avoid inserting a NAV if we already have it
if(!(lastDate instanceof Date) || lastDate.getTime() !== parsedDate.getTime()) {
var nav = s1.getRange(fund.navCell).getValue();
s2.appendRow([ parsedDate, fund.isin, nav ]);
}
});

I set a time driven trigger.
I don't know why but for many NAV i get #error, while if I run the script manually opening the sheet on my PC is works.
Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions