Class PropertiesService  |  Apps Script  |  Google for Developers (original) (raw)

Class PropertiesService

PropertiesService

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. const documentProperties = PropertiesService.getDocumentProperties(); const scriptProperties = PropertiesService.getScriptProperties(); const 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](/apps-script/reference/properties/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](/apps-script/reference/properties/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](/apps-script/reference/properties/properties) — a property store that only the current user of the script can access

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.