Adding timestamp to another spreadsheet every time an update is made on another separate spreadsheet

Viewed 30

I created this spreadsheet with a script that generates a timestamp on another spreadsheet referenced via URL.

The problem is that the URL-referenced spreadsheet is not generating any timestamp every time the other spreadsheet is being updated.

Here is the code that i wrote :

function onEdit(e) {
  addTimestamp(e);

}

function addTimestamp(e){

  var row = e.range.getRow();
  var col = e.range.getColumn();

  if(col >= 1 && col <= 3  && row > 1 && e.source.getActiveSheet().getName() === 'fillForm'){

  var currentDate = new Date();

  SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/1sEwHbKVO7rjbQuEiA6vXN7imn_y072lkgc6q84fNxkw/edit#gid=0').getSheetByName('recapSheet').getRange(row,4).setValue(currentDate);


 }   


}

Did i do something wrong? or is there a work around for this problem?

Thank You, Tom

1 Answers

Remove this piece of code first:

function onEdit(e) {
  addTimestamp(e);
}

Then use a Installable Triggers. The easiest way is to install it manually, it is described here.

Related