google-sheetsgoogle-apps-script

If spreadsheet ID is not equal to and number of rows less than?


Is it possible to create the following logic using Google Script:

(if spreadsheet id is not equal to <id> and number of rows filled on sheet <name> < 100) {
  runFunction()
}
else {
  return dialog window to the user with <text>
}

Solution

  • I'm writing this from memory on my phone but it should be something like this:

    (if SpreadsheetApp.getActiveSpreadsheet().getID() !== id && SpreadsheetApp.getActiveSpreadsheet().getSheetByName(name).getLastRow() < 100) {
      runFunction();
    }
    else {
      SpreadsheetApp.getUi().prompt(text);
    }