如何读取 File/Project 属性菜单中保存的用户属性?

How can I read the User properties saved in the File/Project properties menu?

在 Google Apps 脚本编辑器中,我可以设置用户 属性,方法是打开“文件”>“项目属性”菜单,然后选择“用户属性”选项卡。但是,PropertiesService 似乎无法访问此菜单中设置的值。 有什么方法可以让我在脚本中访问通过此菜单设置的值?

  1. 在“用户属性”选项卡中设置{"属性A", "valueA"}(如图 以下)

  2. 运行 PropertiesService.getUserProperties().getProperties()

  3. 输出:{}

如果我然后 运行 PropertiesService.getUserProperties().setProperty("propertyB", "valueB"); 然后再次 getProperties(),输出将更新为仅显示 {propertyB=valueB}.

同样,由于我的搜索都将我定向到 PropertiesService,我在哪里可以找到有关这些菜单属性的文档? (具体来说,我想知道什么时候应该使用菜单选项而不是通过编程设置值。)

没有。 UserProperties class was deprecated in 2014. The issue was finally resolved with the redesigned Apps Script IDE in 2020 时,用于访问用户属性的 GUI 从未更新,这完全删除了用于访问属性的 GUI。

尽管可以通过菜单访问遗留 IDE 和修改 script 属性,但访问用户属性的唯一方法是以编程方式使用 PropertiesServices.getUserProperties(). Google has also published a guide to the Properties service.