Add item to existing menu in Google Apps Script

Currently it is not possible. Even though the documentation says

A document, spreadsheet, or form can only contain one menu with a given name. If the same script or another script adds a menu with the same name, the new menu will replace the old.

when I tried the following code

DocumentApp.getUi().createMenu('Tools')
  .addItem('Tool_item', 'toolItem')
  .addToUi();

another Tools menu was created:

enter image description here


Yes and no.

Yes, you can add your menu ONLY into the existing 'Add-ons'.

No, but nowhere else other than your own customized menu.

The code below may help:

function onOpen(e) {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createAddonMenu()
    .addItem('Sort Current Column with Header until Blank Rows', 'sortCurrentColumn')
    .addToUi();
}

function onInstall(e) {
    onOpen(e);
}

You can do what you want with custom menus (add, combine...) but you can't in any way modify built in menus, they are not accessible from Google-Apps-Script.