AppScript Deploy Problem

41 views
Skip to first unread message

Frank Hassani

unread,
May 26, 2025, 9:35:09 AMMay 26
to Google Apps Script Community
Hi,
using GPT I have created an AppScript that works, but deploying it doesn't work.
Ive done the cloud.google project number etc.
now I receive an error when deploying, that GPT cant fix

Syntax error: Missing ; before statement. line: 14 file: Code


his is my appscript.json
{
  "timeZone": "Europe/Berlin",
  "oauthScopes": [
  ],
  "addOns": {
    "common": {
      "name": "Menu Tab Generator",
      "useLocaleFromApp": true,
      "homepageTrigger": {
        "runFunction": "onOpen"
      }
    },
    "sheets": {}
  }
}
this is my code.gs
function onOpen(e) {
  const ui = SpreadsheetApp.getUi();
  ui.createAddonMenu()
    .addItem("🔄 Generate Tab Links", "runMenuScript")
    .addToUi();
}

function onInstall(e) {
  onOpen(e); // ensure menu shows up after install
}

function runMenuScript() {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  let menuSheet = ss.getSheetByName("Menu");
  if (!menuSheet) {
    menuSheet = ss.insertSheet("Menu");
  }

  const allSheets = ss.getSheets();

  menuSheet.clear();
  menuSheet.clearFormats();
  if (menuSheet.getMaxRows() > 1) {
    menuSheet.deleteRows(2, menuSheet.getMaxRows() - 1);
  }
  if (menuSheet.getMaxColumns() > 1) {
    menuSheet.deleteColumns(2, menuSheet.getMaxColumns() - 1);
  }

  let row = 1;
  for (const sheet of allSheets) {
    const name = sheet.getName();
    const gid = sheet.getSheetId();
    const formula = `=HYPERLINK("#gid=${gid}", "${name}")`; // ← fixed here

    const cell = menuSheet.getRange(row, 1);
    cell.setFormula(formula);

    const bgColor = sheet.getRange("A1").getBackground();
    cell.setBackground(bgColor);

    const richText = cell.getRichTextValue();
    if (richText) {
      const style = SpreadsheetApp.newTextStyle()
        .setForegroundColor("#000000")
        .setUnderline(false)
        .build();

      const styled = richText.copy()
        .setTextStyle(0, name.length, style)
        .build();

      cell.setRichTextValue(styled);
    }

    row++;
  }

  menuSheet.autoResizeColumn(1);
  SpreadsheetApp.getUi().alert("✅ Tab links generated in sheet: 'Menu'");
}

Kim Nilsson

unread,
May 26, 2025, 1:18:11 PMMay 26
to Google Apps Script Community
I'm fairly sure I found your error.

Your manifest is missing a few lines I usually have, and it turns out removing one of them causes exact your error.

I tested your code, but only added your code to the default manifest.

My manifest looks like this, and works.

{
  "timeZone": "Europe/Berlin",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "oauthScopes": [
  ],
  "addOns": {
    "common": {
      "name": "Menu Tab Generator",
      "useLocaleFromApp": true,
      "homepageTrigger": {
        "runFunction": "onOpen"
      }
    },
    "sheets": {}
  }
}

Removing the line about runtimeVersion breaks the script with the error you get.

So, without this line, the script doesn't want to save.

 "runtimeVersion": "V8",

Removing the lines about dependencies or logging doesn't interfere with saving, only removing runtime does.
Message has been deleted

Frank Hassani

unread,
Jun 9, 2025, 1:36:28 PM (2 days ago) Jun 9
to Google Apps Script Community
Thank you Kim, works now like a charm :)
Reply all
Reply to author
Forward
0 new messages