# event: onEdit

{% tabs %}
{% tab title="💾 程式" %}

```javascript
/**
 * onOpen()
 */
function onOpen() {
  // app UI
  var ui = SpreadsheetApp.getUi();
  
  // ♥ 自製工具
  ui.createMenu('🧰 工具箱')
    .addItem('❶ 原始報表 ➠ 生成資料', 'init')        
    .addToUi();
}

/**
 * onEdit(e)
 * triggered when editing the spreadsheet.
 * @param {Event} e The onEdit event.
 */
function onEdit(e) {

  // ⭐️ edited cell
  var range = e.range;
  let rngGrade = App.range.byName('Grade');

  // 不是「高一、高二、高三」那一格，就請回。
  if (!App.isSameRange(range, rngGrade)) return;
  App.updateCurrentClasses();
}
```

{% endtab %}

{% tab title="📘 手冊" %}

* [Events](https://developers.google.com/apps-script/guides/triggers/events?hl=en)
  {% endtab %}

{% tab title="👥 相關" %}

* [app menu](/web/appendix/gas/app/app-menu.md)
  {% endtab %}
  {% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lochiwei.gitbook.io/web/appendix/gas/examples/event-onedit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
