Skip to content

Diagnostic reference

Attempted to execute myFunction, but it was deleted

Fix Apps Script's 'Attempted to execute myFunction, but it was deleted' error after renaming the starter function, skipping a save, or leaving an old trigger.

Updated November 26, 2026

Apps Script error

Attempted to execute myFunction, but it was deleted.

What it means

Every new Apps Script project starts with a placeholder named myFunction. After you rename or delete myFunction, the toolbar dropdown, an unsaved file, or an installed trigger can still ask for the old name. Apps Script then stops because the saved project has no function with that name.

Related error messages

  • Script function not found: myFunction
  • Attempted to execute <functionName>, but it was deleted.

Before and after

The code before and after the fix.

Problem 2 changed lines
// The starter function was renamed to logSummary,
// while the toolbar dropdown or a trigger still targets myFunction.
function logSummary() {
  Logger.log('Summary ready.');
}
Fixed 3 changed lines
// 1. Save the file (Ctrl+S or Cmd+S).
// 2. Pick logSummary in the function dropdown beside Run.
// 3. Recreate any trigger that still targets myFunction.
function logSummary() {
  Logger.log('Summary ready.');
}

How to fix it

  • Press Ctrl+S (or Cmd+S on macOS) so the editor refreshes its saved function list.
  • Open the function dropdown next to Run and select the new function name.
  • If the failure came from a trigger, open Triggers in the left sidebar and delete the old trigger. Then add a new trigger for the renamed function.
  • If the failure came from a sheet button or custom menu, update the assigned script name or reload the spreadsheet after editing onOpen().

Things to check

  • Renaming a function in Code.gs never updates installed triggers, assigned drawings, or open menus.
  • Reload the Apps Script editor tab if the toolbar dropdown still lists myFunction after you save.

In the Apps Script editor

Catch errors like this before clicking Run.

myFunction (published as Error Checker for Google Apps Script on the Chrome Web Store) checks your code while you edit at script.google.com. Diagnostics, autocomplete, and rule-based quick fixes are free without an account, run in your browser, and request no Google Drive, Gmail, or Apps Script project OAuth scopes.