functiononOpen(e){varmenu=SpreadsheetApp.getUi().createAddonMenu();//OrDocumentApporSlidesApporFormApp.if(e && e.authMode==ScriptApp.AuthMode.NONE){//Addanormalmenuitem(worksinallauthorizationmodes).menu.addItem('Start workflow','startWorkflow');}else{//Addamenuitembasedonproperties(doesn't work in AuthMode.NONE).varproperties=PropertiesService.getDocumentProperties();varworkflowStarted=properties.getProperty('workflowStarted');if(workflowStarted){menu.addItem('Check workflow status','checkWorkflow');}else{menu.addItem('Start workflow','startWorkflow');}//Recordanalytics.UrlFetchApp.fetch('http://www.example.com/analytics?event=open');}menu.addToUi();}
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-12-18 (世界標準時間)。"],[[["Published Editor Add-ons can create custom menu items under the Extensions menu using `Ui.createAddonMenu()` and `Menu.addItem()`, typically within the add-on's `onOpen(e)` method."],["While unpublished add-ons can create top-level menus, it's recommended to use `Ui.createAddonMenu()` for published add-ons to ensure consistent user experience."],["Add-ons must create an initial menu before user authorization and adjust menu items dynamically based on the authorization mode (`ScriptApp.AuthMode`) to avoid errors."],["The provided example demonstrates building a dynamic add-on menu that adapts to different authorization modes, using `ScriptApp.AuthMode.NONE` to control actions requiring authorization."]]],[]]