Allows scripts to store simple data in key-value pairs scoped to one script, one user of a script, or one document in which an add-on is used. Properties cannot be shared between scripts. For more information about when to use each type of property, see the guide to the Properties service.
// Sets three properties of different types. var documentProperties = PropertiesService.getDocumentProperties(); var scriptProperties = PropertiesService.getScriptProperties(); var userProperties = PropertiesService.getUserProperties(); documentProperties.setProperty('DAYS_TO_FETCH', '5'); scriptProperties.setProperty('SERVER_URL', 'http://www.example.com/MyWeatherService/'); userProperties.setProperty('DISPLAY_UNITS', 'metric');
Methods
Method | Return type | Brief description |
---|---|---|
getDocumentProperties() | Properties | Gets a property store (for this script only) that all users can access within the open document, spreadsheet, or form. |
getScriptProperties() | Properties | Gets a property store that all users can access, but only within this script. |
getUserProperties() | Properties | Gets a property store that only the current user can access, and only within this script. |
Detailed documentation
getDocumentProperties()
Gets a property store (for this script only) that all users can access within the open
document, spreadsheet, or form. It is only available if the script is published and executing
as an add-on or if it is bound to a Google file
type. When document properties are not available this method returns null
. Document
properties created by a script are not accessible outside that script, even by other scripts
accessing the same document.
Return
Properties
— a property store for this script only that all users of the current document can
access, or null
if the script is not either an add-on or bound to a Google
Workspace file
getScriptProperties()
Gets a property store that all users can access, but only within this script.
Return
Properties
— a property store that all users of the script can access
getUserProperties()
Gets a property store that only the current user can access, and only within this script.
Return
Properties
— a property store that only the current user of the script can access