Class Service
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
บริการ
เข้าถึงและจัดการการเผยแพร่สคริปต์
เมธอด
วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ |
getUrl() | String | แสดงผล URL ของเว็บแอป หากมีการใช้งาน มิเช่นนั้นระบบจะแสดงผล null |
isEnabled() | Boolean | แสดงผลเป็น true หากเข้าถึงสคริปต์เป็นเว็บแอปได้ |
วิธีการที่เลิกใช้งาน
วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ |
disable()
| void | ปิดใช้การเข้าถึงสคริปต์ในฐานะเว็บแอป |
เอกสารประกอบโดยละเอียด
getUrl()
แสดงผล URL ของเว็บแอป หากมีการใช้งาน มิเช่นนั้นระบบจะแสดงผล null
หากคุณใช้เว็บแอปโหมดการพัฒนาอยู่ การดำเนินการนี้จะแสดงผล URL ของโหมดการพัฒนา
// Mail the URL of the published web app.
MailApp.sendMail(
'myself@example.com',
'My Snazzy App',
`My new app is now available at ${ScriptApp.getService().getUrl()}`,
);
รีเทิร์น
String
— URL ของเว็บแอป
isEnabled()
แสดงผลเป็น true
หากเข้าถึงสคริปต์เป็นเว็บแอปได้
รีเทิร์น
Boolean
— true
หากสคริปต์เผยแพร่เป็นเว็บแอป false
หากไม่ใช่
วิธีการที่เลิกใช้งาน
disable()
เลิกใช้งานแล้ว ฟังก์ชันนี้เลิกใช้งานแล้วและไม่ควรนำมาใช้ในสคริปต์ใหม่
ปิดใช้การเข้าถึงสคริปต์เป็นแอปพลิเคชันเว็บ วิธีนี้เทียบเท่ากับการเปิดกล่องโต้ตอบ "เผยแพร่ > ใช้งานเป็นแอปพลิเคชันเว็บ" แล้วคลิก "ปิดใช้แอปพลิเคชันเว็บ"
ScriptApp.getService().disable();
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eThe \u003ccode\u003eScriptApp\u003c/code\u003e service allows you to control and interact with the deployment of your script as a web application.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve the web app's URL using \u003ccode\u003egetUrl()\u003c/code\u003e, check its accessibility status with \u003ccode\u003eisEnabled()\u003c/code\u003e, and previously, disable it using the now deprecated \u003ccode\u003edisable()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edisable()\u003c/code\u003e method has been deprecated and should no longer be used in new scripts, replaced by the "Publish > Deploy as web app" dialog for disabling.\u003c/p\u003e\n"],["\u003cp\u003eWhen deploying your script as a web app, you can use provided methods to obtain its URL and determine if it's enabled for access.\u003c/p\u003e\n"]]],[],null,["# Class Service\n\nService\n\nAccess and manipulate script publishing. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------|-------------|------------------------------------------------------------------------------------|\n| [getUrl()](#getUrl()) | `String` | Returns the URL of the web app, if it has been deployed; otherwise returns `null`. |\n| [isEnabled()](#isEnabled()) | `Boolean` | Returns `true` if the script is accessible as a web app. |\n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|-------------------------|-------------|-------------------------------------------------------|\n| [disable()](#disable()) | `void` | Disables the script from being accessed as a web app. |\n\nDetailed documentation\n----------------------\n\n### `get``Url()`\n\nReturns the URL of the web app, if it has been deployed; otherwise returns `null`. If you\nare running the development mode web app, this returns the development mode url.\n\n```javascript\n// Mail the URL of the published web app.\nMailApp.sendMail(\n 'myself@example.com',\n 'My Snazzy App',\n `My new app is now available at ${ScriptApp.getService().getUrl()}`,\n);\n```\n\n#### Return\n\n\n`String` --- the URL of the web app\n\n*** ** * ** ***\n\n### `is``Enabled()`\n\nReturns `true` if the script is accessible as a web app.\n\n#### Return\n\n\n`Boolean` --- `true` if the script is published as a web app; `false` if not\n\nDeprecated methods\n------------------\n\n### `disable()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nDisables the script from being accessed as a web app. This method is equivalent to opening the\n\"Publish \\\u003e Deploy as web app\" dialog and clicking \"disable web app\".\n\n```javascript\nScriptApp.getService().disable();\n```"]]