Class Properties Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The properties object allows access to user, document, or script properties through methods of the
PropertiesService.Properties cannot be shared between different scripts.
The
Propertiesobject includes methods for deleting properties, retrieving keys or all properties, and setting individual or multiple properties.
The properties object acts as the interface to access user, document, or script properties. Thespecific property type depends on which of the three methods ofProperties thescript called:Properties,Properties, orProperties.Properties cannot be shared between scripts. For more information about property types, see theguide to the Properties service.
Methods
| Method | Return type | Brief description |
|---|---|---|
delete | Properties | Deletes all properties in the currentProperties store. |
delete | Properties | Deletes the property with the given key in the currentProperties store. |
get | String[] | Gets all keys in the currentProperties store. |
get | Object | Gets a copy of all key-value pairs in the currentProperties store. |
get | String | Gets the value associated with the given key in the currentProperties store, ornull if no such key exists. |
set | Properties | Sets all key-value pairs from the given object in the currentProperties store. |
set | Properties | Sets all key-value pairs from the given object in the currentProperties store,optionally deleting all other properties in the store. |
set | Properties | Sets the given key-value pair in the currentProperties store. |
Detailed documentation
deleteAllProperties()
Deletes all properties in the currentProperties store.
// Deletes all user properties.constuserProperties=PropertiesService.getUserProperties();userProperties.deleteAllProperties();
Return
Properties — thisProperties store, for chaining
deleteProperty(key)
Deletes the property with the given key in the currentProperties store.
// Deletes the user property 'nickname'.constuserProperties=PropertiesService.getUserProperties();userProperties.deleteProperty('nickname');
Parameters
| Name | Type | Description |
|---|---|---|
key | String | the key for the property to delete |
Return
Properties — thisProperties store, for chaining
getKeys()
Gets all keys in the currentProperties store.
// Sets several properties, then logs the value of each key.constscriptProperties=PropertiesService.getScriptProperties();scriptProperties.setProperties({cow:'moo',sheep:'baa',chicken:'cluck',});constkeys=scriptProperties.getKeys();Logger.log('Animals known:');for(leti=0;i <keys.length;i++){Logger.log(keys[i]);}
Return
String[] — an array of all keys in the currentProperties store
getProperties()
Gets a copy of all key-value pairs in the currentProperties store. Note that thereturned object is not a live view of the store. Consequently, changing the properties on thereturned object will not automatically update them in storage, or vice versa.
// Sets several script properties, then retrieves them and logs them.constscriptProperties=PropertiesService.getScriptProperties();scriptProperties.setProperties({cow:'moo',sheep:'baa',chicken:'cluck',});constanimalSounds=scriptProperties.getProperties();// Logs:// A chicken goes cluck!// A cow goes moo!// A sheep goes baa!for(constkindinanimalSounds){Logger.log('A %s goes %s!',kind,animalSounds[kind]);}
Return
Object — a copy of all key-value pairs in the currentProperties store
getProperty(key)
Gets the value associated with the given key in the currentProperties store, ornull if no such key exists.
// Gets the user property 'nickname'.constuserProperties=PropertiesService.getUserProperties();constnickname=userProperties.getProperty('nickname');Logger.log(nickname);
Parameters
| Name | Type | Description |
|---|---|---|
key | String | the key for the property value to retrieve |
Return
String — the value associated with the given key in the currentProperties store
setProperties(properties)
Sets all key-value pairs from the given object in the currentProperties store.
// Sets multiple user properties at once.constuserProperties=PropertiesService.getUserProperties();constnewProperties={nickname:'Bob',region:'US',language:'EN'};userProperties.setProperties(newProperties);
Parameters
| Name | Type | Description |
|---|---|---|
properties | Object | an object containing key-values pairs to set |
Return
Properties — thisProperties store, for chaining
setProperties(properties, deleteAllOthers)
Sets all key-value pairs from the given object in the currentProperties store,optionally deleting all other properties in the store.
// Sets multiple user properties at once while deleting all other user// properties.constuserProperties=PropertiesService.getUserProperties();constnewProperties={nickname:'Bob',region:'US',language:'EN'};userProperties.setProperties(newProperties,true);
Parameters
| Name | Type | Description |
|---|---|---|
properties | Object | an object containing key-values pairs to set |
delete | Boolean | true to delete all other key-value pairs in the properties object;false to not |
Return
Properties — thisProperties store, for chaining
setProperty(key, value)
Sets the given key-value pair in the currentProperties store.
// Sets the user property 'nickname' to 'Bobby'.constuserProperties=PropertiesService.getUserProperties();userProperties.setProperty('nickname','Bobby');
Parameters
| Name | Type | Description |
|---|---|---|
key | String | the key for the property |
value | String | the value to associate with the key |
Return
Properties — thisProperties store, for chaining
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.