Home > database >  Reference data from cell then timestamp it
Reference data from cell then timestamp it

Time:04-13

I am currently using Sheetgo to timestamp data. Unfortunately my trial is about to expire. I'm assuming a script with a trigger would provide me with the same results, but I am unsure how to go about it.

I am pulling the value "A1" from an api: enter image description here

Sheetgo then logs the value every hour on a separate sheet: enter image description here

Any assistance with creating a script/trigger that could perform this task would be much appreciated. Thanks.

CodePudding user response:

Logging a value every hour

function getA1() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName("Sheet0");//wherever the data is
  const A1 = sh.getRange("A1").getValue();//wherever the data is
  ss.getSheetByName("log").appendRow([A1,new Date()]);
}

Run the following atleast once

function ctrig() {
  if(ScriptApp.getProjectTriggers().filter(t => t.getHandlerFunction() == "getA1").length == 0) {
    ScriptApp.newTrigger("getA1").timeBased().everyHours(1).create();
  }
}

Script App newTrigger

  • Related