Home > Software engineering >  Add submenu inside other submenu in Google Apps Script
Add submenu inside other submenu in Google Apps Script

Time:03-08

So, I'm coding in Google Apps Script, and I neet to make a second level submenu, but everytime I try to add the following code, I get the error from the 2nd image:

var ui = SpreadsheetApp.getUi();
  ui.createMenu('WB_Tools')
    .addSubMenu(ui.createMenu('LE Ready')
      .addSubMenu(ui.createMenu('Generate E-mail'))
        .addItem('SMR', 'WB_Tools.GENERATELESMRREADY')
        .addItem('Non SMR', 'WB_Tools.GENERATELENPIREADY')
      .addSeparator()
      .addItem('Add to SMR/MR Pending tool', 'WB_Tools.ADDPENDINGACT')
      .addItem('Update SMR/MR Dashboard', 'WB_Tools.UPDATEDASHBOARD'))
    .addSeparator()

error

With that, I must show you the line 62 of the file: line 62

So, what should I do to achieve the following:

Global menu

  • First submenu
    • Second submenu
      • Item 1
      • Item 2
    • Item 3
    • Item 4

CodePudding user response:

Try this:

.addSubMenu(SpreadsheetApp.getUi().createMenu('TestData')
              .addItem('testDataFixedHeaders(1)', 'testDataFixedHeaders')
              .addItem('testDataRandowHeaders(1)', 'testDataRandowHeaders')
              .addItem('testDataWrappedText','testDataWrpdStrings1')
              .addItem('testData1(2)', 'testData1')
              .addItem('testData2(2)', 'testData2')
              .addItem('testData3(2)', 'testData3')
              .addItem('testData4(2)', 'testData4')
              .addItem('testData5(3)', 'testData5')
              .addItem('testData6(3)', 'testData6')
              .addItem('testData7(3)', 'testData7')
              .addItem('testData8(3)', 'testData8')
              .addSubMenu(SpreadsheetApp.getUi().createMenu('sub sub')
              .addItem('new','elfunko')))
  • Related