0
votes

I have a google sheet with some script running behind it. I've had to separate some of the tabs out to individual workbooks, and have been updating the script accordingly. One of the functions I had was an onEdit(e) trigger, that was no longer running in the new workbook. As part of my testing, I've simplified it to just:

function onEdit(e) {
  Logger.log("TEST");
}

No matter the changes I make in the sheet this is attached to, the Logger.log never writes.

I've done some research, especially into the simple trigger restrictions, and one of those relates to openByURL, which I am using elsewhere in the script.

var otherBook = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/etcetc/edit');

Even though the onEdit(e) doesn't directly relate, is the presence of the openByUrl within the script what is preventing the onEdit(e) from running? If so, are there ways to get around that, so that I can trigger actions based on an edit, but also be able to pull data from an alternate workbook?

2

2 Answers

0
votes

I inserted the following into a new script and the onEdit(e) worked without an issue. To call functions from onEdit that are restricted for simple triggers, install the trigger instead and set it to fire on spreadsheet edit.

function onEdit(e) {
  Logger.log("TEST2");
}

function test() {
  var otherBook = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/etcetc/edit');
}
-1
votes

Regarding the Logger, can you try:

Logger.log(["TEST"]); instead of Logger.log("TEST");

Your login line does not work for me either but works with the brackets.