N
N
Natalya Bobrovskaya2020-06-08 23:14:11
Google Apps Script
Natalya Bobrovskaya, 2020-06-08 23:14:11

Why does the log fail "Can't call function SpreadsheetApp.getUi() from this context menu"?

Google Sheets creates a sheet that is populated with data from a third-party application. After that, you need to change some data in the cells.
Execution fails when calling onChange function in trigger log

"Cannot call SpreadsheetApp.getUi() function from this context menu. at [unknown function].


function createTable(
  tableName,
  spreadsheet = SpreadsheetApp.getActiveSpreadsheet()
) {
  try {
    spreadsheet.insertSheet(tableName);
    spreadsheet.getSheetByName(settings.listName).activate();
  } catch (err) {
    return err;
  }
}
function onChange() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var sheetRows = sheet.getMaxRows();
  for (var row = 2; row <= sheetRows; row++) {
    let current_cell_value = sheet.getRange(row, 5, 1, 1).getValue();
    if (current_cell_value.includes('ааа')) {
      sheet.getRange(row, 1, 1, 1).setValue('bbb');
    }
  }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question