如何在新的 Google Apps 脚本 IDE 中查看脚本属性

How do I view Script Properties in the new Google Apps Script IDE

我已经切换到新的 Google Apps 脚本 IDE。我以前可以单击 FILE > PROJECT PROPERTIES 访问文件的全局属性

我这辈子都找不到你现在怎么到那里了??

有人知道吗?

p.s我现在可以切换回旧版,但一旦删除就没用了....

此功能已在 issue tracker 中报告为未来的请求:

Star ⭐ 请求并使其更显眼。

显然,google 开发人员回复了以下内容:

Unfortunately, even though I couldn't find the script properties either, this is a feature related to the new editor rather than directly to Apps Script functionallities or its API.

Therefore, the right place to file this feature request is on the top right question mark button of the editor and then selecting Send feedback as this will send your feature request to the right team.

希望它能尽快得到解决,但您可以通过单击开始按钮来提高它的受欢迎程度。

问题解决前的解决方法:

通过 PropertiesService class:

访问项目属性

console.log(PropertiesService.getScriptProperties().getProperties());

要查看、更改或删除脚本属性,最可靠的方法是编写一些使用属性服务的代码。

例如,您可以按如下方式记录脚本 属性 值:

function getAllScriptProps() {

  var v = PropertiesService.getScriptProperties().getProperties();
  Logger.log(v)
}

您可以继续使用旧版编辑器查看和管理脚本属性,但 UI 一直存在错误。 它将显示脚本属性,但并不总是正确更新或删除属性。

脚本属性是属性服务的一部分,它独立于 Apps 脚本 API。属性可以绑定到用户、文档或 Apps 脚本项目文件。即使 Apps 脚本 API 用于访问 Apps 脚本文件,它也无法列出或更新脚本属性。

新 IDE 的功能似乎与 Apps 脚本 API 可以访问的内容密切相关。

如果他们决定允许新的 IDE 权限访问您的脚本属性,并添加 UI 来管理它们,可能会在发行说明中公布。

Apps Script Release Notes

我猜旧版编辑器最终会被弃用,如果用于管理脚本属性的新 UI 没有实现,那么您将需要使用代码。

我在 Apps 脚本新编辑器中调整时区时遇到了同样的问题。我发现最简单的方法是点击新编辑器右上角的 Use Legacy editor。然后我检索了遗留文件菜单。设置好时区后,我点了【=11=】。当我返回到新编辑器时,设置得以保持。

它在新编辑器中的外观:

旧版编辑器中的外观:

2022 年 4 月 13 日

根据 2022 年 4 月 13 日 "Additional functionality for the Apps Script Integrated Development Environment (IDE) Script Editor" and Release Notes 的报告,终于可以在新 IDE 上管理脚本属性了。

官方文档如下。 https://developers.google.com/apps-script/guides/properties#manage_script_properties_manually

You can manually add up to fifty custom properties, as strings in key-value pairs, from the project settings page. To add more than fifty properties, you need to add them programmatically using the methods described above in Saving data. When you set script properties from the project settings page, you can’t reference script variables.

注:

  • 今天,我确认脚本属性必须能够使用 gmail 帐户进行管理。所以,我发布了这个。