Class UserProperties

  • This class is deprecated and should not be used in new scripts.

  • User Properties are key-value pairs unique to a user.

  • User Properties are scoped per user, meaning a script can only access properties for the user running the script.

UserProperties

Deprecated. This class is deprecated and should not be used in new scripts.

User Properties are key-value pairs unique to a user. User Properties are scoped per user; anyscript running under the identity of a user can access User Properties for that user only.

Deprecated methods

MethodReturn typeBrief description
deleteAllProperties()UserPropertiesDeletes all properties.
deleteProperty(key)UserPropertiesDeletes the property with the given key.
getKeys()String[]Get all of the available keys.
getProperties()ObjectGet all of the available properties at once.
getProperty(key)StringReturns the value associated with the provided key, or null if there is no such value.
setProperties(properties)UserPropertiesBulk-sets all the properties drawn from the given object.
setProperties(properties, deleteAllOthers)UserPropertiesBulk-sets all the properties drawn from the given object.
setProperty(key, value)UserPropertiesPersists the specified in value with the provided key.

Deprecated methods

deleteAllProperties()

Deprecated. This function is deprecated and should not be used in new scripts.

Deletes all properties.

UserProperties.deleteAllProperties();

Return

UserProperties — this object, for chaining

See also


deleteProperty(key)

Deprecated. This function is deprecated and should not be used in new scripts.

Deletes the property with the given key.

UserProperties.deleteProperty('special');

Parameters

NameTypeDescription
keyStringkey for property to delete

Return

UserProperties — this object, for chaining

See also


getKeys()

Deprecated. This function is deprecated and should not be used in new scripts.

Get all of the available keys.

Return

String[]


getProperties()

Deprecated. This function is deprecated and should not be used in new scripts.

Get all of the available properties at once.

This gives a copy, not a live view, so changing the properties on the returned object won'tupdate them in storage and vice versa.

UserProperties.setProperties({"cow":"moo","sheep":"baa","chicken":"cluck"});// Logs "A cow goes: moo"Logger.log("A cow goes: %s",UserProperties.getProperty("cow"));// This makes a copy. Any changes that happen here will not// be written back to properties.varanimalSounds=UserProperties.getProperties();// Logs:// A chicken goes cluck!// A cow goes moo!// A sheep goes baa!for(varkindinanimalSounds){Logger.log("A %s goes %s!",kind,animalSounds[kind]);}

Return

Object — a copy of the properties containing key-value pairs


getProperty(key)

Deprecated. This function is deprecated and should not be used in new scripts.

Returns the value associated with the provided key, or null if there is no such value.

constspecialValue=UserProperties.getProperty('special');

Parameters

NameTypeDescription
keyStringkey for the value to retrieve

Return

String — the value associated with the key

See also


setProperties(properties)

Deprecated. This function is deprecated and should not be used in new scripts.

Bulk-sets all the properties drawn from the given object.

UserProperties.setProperties({special:'sauce','meaning':42});

Parameters

NameTypeDescription
propertiesObjectan object containing the properties to set.

Return

UserProperties — this object, for chaining

See also


setProperties(properties, deleteAllOthers)

Deprecated. This function is deprecated and should not be used in new scripts.

Bulk-sets all the properties drawn from the given object.

// This deletes all other propertiesUserProperties.setProperties({special:'sauce','meaning':42},true);

Parameters

NameTypeDescription
propertiesObjectan object containing the properties to set.
deleteAllOthersBooleanwhether to delete all existing properties.

Return

UserProperties — this object, for chaining

See also


setProperty(key, value)

Deprecated. This function is deprecated and should not be used in new scripts.

Persists the specified in value with the provided key. Any existing value associated with thiskey will be overwritten.

UserProperties.setProperty('special','sauce');

Parameters

NameTypeDescription
keyStringkey for property
valueStringvalue to associate with the key

Return

UserProperties — this object, for chaining

See also

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.