Google SpreadSheets - When using a time trigger in code, some cells getting '#N/A' value
- by Robi
I've created a Google spreadsheet with imported data on one cell, extracting specific string to another cell and pasting the data in a table with a trigger for every 2 hours.
Now everything works perfectly when running the script manually but when logged out and waiting for the cells to fill, sometimes the pasted cell getting "#N/A" value.
Here is the code I'm using:
function PasteV(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var timestamp= sheet.getRange("D1").getValue();
var sale= sheet.getRange("G1").getValue();
var rent= sheet.getRange("J1").getValue();
sheet.appendRow([timestamp, rent, sale]);
}
Again when running manually countless times - no problem.
I'll appreciate your help.
Thanks.