OnOpen Is Not Running To Other Users Except To The Owner. How To Fix This? Google Script GAS

After refreshing the shared spreadsheet, onOpen is not running to other users who also have access.

But the owner is being able to run the codes and script.

function onOpen(e) {
  SpreadsheetApp.getUi() // Or DocumentApp, SlidesApp, or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
    SpreadsheetApp.getUi() // Or DocumentApp, SlidesApp, or FormApp.
        .createMenu('Custom Menu').addItem('Test', 'test').addToUi();

function test() {
    var ui = SpreadsheetApp.getUi(); // Same variations.
    var result = ui.prompt('Spreadsheet Restriction', 'Enter password:', ui.ButtonSet.OK);
    // Process the user's response.
    var button = result.getSelectedButton();
    var text = result.getResponseText();
    if (button == ui.Button.OK) {
        // User clicked "OK".
    } else if (button == ui.Button.CLOSE) {
        // User clicked X in the title bar.
        ui.alert('Spreadsheet is protected.');
function myFunction() {


Already shared the access spreadsheet and script to other users but they can't still see it is working. Appreciate your help guys... Thanks!



  1. The users of your Sheet/script must have edit access on the Sheets document in order for the onOpen() trigger to be executed. From the documentation:

    They do not run if a file is opened in read-only (view or comment) mode.

  2. In order to use the prompt() method within the onOpen() function, you must use an installable trigger. Furthermore, the trigger must be set up by the user who is going to use it. The same also applies to other functions of the UI class such as showModalDialog().

This strict rules are most likely enforced in order to protect the end user of potential scams. If you are interested in protecting your Sheets document with password, I suggest you check out other solutions such as this one,