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

1

9

In the Google Apps Script editor, I can set a user property by opening the File > Project properties menu, and then selecting the "User properties" tab. However, it seems that the PropertiesService is unable to access the values set in this menu. Is there a way I can access the values set through this menu in my script?

  1. Set {"propertyA", "valueA"} in "User Properties" tab (pictured below) "User Properties" tab

  2. Run PropertiesService.getUserProperties().getProperties()

  3. Output: {}

If I were to then run PropertiesService.getUserProperties().setProperty("propertyB", "valueB"); and then getProperties() again, the output would update to show only {propertyB=valueB}.

Similarly, as my searches all direct me to the PropertiesService, where can I find documentation about these menu properties? (Specifically, I'd like to know when I should use the menu option versus setting the values programatically.)

Doig answered 18/1, 2018 at 3:42 Comment(3)
Is this thread helpful for you? #24909299Windbound
@Windbound It was, thank you. I haven't tested it, but it seems the UI is accessed via a deprecated method. Reading through that thread also inspired me to look through Google's issue tracker and, indeed, the bug was reported a few years ago and seems to have been assigned in early 2017. issuetracker.google.com/issues/36762534Doig
Thank you for the additional information.Windbound
D
4

No. The GUI for accessing user properties was never updated when the UserProperties class was deprecated in 2014. The issue was finally resolved with the redesigned Apps Script IDE in 2020, which removed the GUI for accessing properties altogether.

Although it is possible to access the legacy IDE and modify script properties via the menu, the only way to access user properties is programmatically with PropertiesServices.getUserProperties(). Google has also published a guide to the Properties service.

Doig answered 24/11, 2021 at 5:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.