Run menu shows “No functions” when gmail.gs is open, and its functions don’t seem to execute

53 views
Skip to first unread message

Márton Jakab

unread,
Sep 23, 2025, 2:55:25 AMSep 23
to Google Apps Script Community

Hi all — I’m seeing a weird editor/runtime mismatch isolated to gmail.gs.

What I see

  • If the editor tab is gmail.gs, the Run button is grey and the function dropdown says “No functions”.

  • If I switch to any other file (e.g., main.gs), the Run button becomes active and other functions run fine.

  • However, functions inside gmail.gs (e.g., previewGmail_) never appear in the dropdown, and when I call them indirectly from main.gs, I don’t get any output (no email/logs) and no explicit error — the execution log just says “started/finished.”

Environment

  • New Apps Script editor, V8 runtime.

  • Consumer Gmail account.

  • Other parts work: Drive folder creation, Sheets writes, success email — all OK.

  • appsscript.json has these scopes:

    • .../auth/drive

    • .../auth/spreadsheets

    • .../auth/gmail.readonly

    • .../auth/gmail.modify

    • .../auth/script.send_mail

What I tried

  • Save all files, hard refresh, switch back to Editor view from Execution log.

  • Created a brand-new script project and pasted only gmail.gs below → same result.

  • If I comment out the entire gmail.gs, the Run menu works normally for the rest of the project.

Question
Is there a known issue that would make the editor fail to recognize top-level functions in a specific .gs file (and disable Run while that tab is focused)? Any parser quirks I might be hitting with the code below?

Minimal gmail.gs (standalone):

/** Return INBOX messages since cutoff that match subject or special sender. */
function gmailFindCandidates_() {
  var cutoff = getCutoff_();
  var afterDay = Utilities.formatDate(cutoff, SETTINGS.TIMEZONE, "yyyy/MM/dd"); // Gmail after: is day-based

  var q1 = 'in:inbox subject:"Teszt - Megrendelés (" after:' + afterDay;
  var q2 = 'in:inbox from:szal...@teszt.hu after:' + afterDay;

  var threads = GmailApp.search(q1).concat(GmailApp.search(q2));
  var seen = {};
  var msgs = [];

  for (var t = 0; t < threads.length; t++) {
    var list = threads[t].getMessages();
    for (var i = 0; i < list.length; i++) {
      var m = list[i];
      var id = m.getId();
      if (seen[id]) continue; // dedupe across queries
      seen[id] = true;
      if (m.getDate().getTime() > cutoff.getTime()) {
        msgs.push(m);
      }
    }
  }

  // Oldest → newest
  msgs.sort(function (a, b) { return a.getDate().getTime() - b.getDate().getTime(); });
  return msgs;
}

/** Preview: logs candidate emails (date, from, subject, ids). */
function previewGmail_() {
  var cutoff = getCutoff_();
  var msgs = gmailFindCandidates_();
  Logger.log("Cutoff: %s | Candidates: %s", fmtTZ(cutoff, "yyyy.MM.dd HH:mm"), msgs.length);
  for (var i = 0; i < msgs.length; i++) {
    var m = msgs[i];
    Logger.log(
      "%s) %s | from=%s | subj=%s | msgId=%s | threadId=%s",
      (i + 1),
      fmtTZ(m.getDate(), "yyyy.MM.dd HH:mm"),
      m.getFrom(),
      m.getSubject(),
      m.getId(),
      m.getThread().getId()
    );
  }
}

(In my project, helper functions getCutoff_() and fmtTZ() live in another file; in a fresh repro I stubbed them, but the editor still greys out the Run menu whenever gmail.gs is the active tab.)

Any ideas or known editor bugs I should be aware of? Thanks!

Valentin Stepaniuk

unread,
Sep 23, 2025, 3:15:37 AMSep 23
to google-apps-sc...@googlegroups.com
Why an underscore in the end

To: Google Apps Script Community <google-apps-sc...@googlegroups.com>;
Subject: [Apps-Script] Run menu shows “No functions” when gmail.gs is open, and its functions don’t seem to execute;
23.09.2025, 09:55, "Márton Jakab" <vitami...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/3916b9b2-7ec6-4a5c-b366-998dfcc66665n%40googlegroups.com.

Andrew Roberts

unread,
Sep 23, 2025, 1:05:52 PMSep 23
to google-apps-sc...@googlegroups.com
The underscore hides the functions as it makes them private.

Keith Andersen

unread,
Sep 23, 2025, 1:17:53 PMSep 23
to google-apps-sc...@googlegroups.com
Andrew,
I know leading function names with and underscore causes them to be invisible... but does a trailing underscore also cause it to be invisible?



My website: https://sites.google.com/view/klaweb/
Passions: God, Family, Scriptures, Learning, Data Management, Google Sheets + App Script and much more!

Márton Jakab

unread,
Sep 25, 2025, 6:35:50 AMSep 25
to Google Apps Script Community
All sorted! Thank you so much for your response!
Reply all
Reply to author
Forward
0 new messages