Class ScriptProperties

ScriptProperties

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

Script Properties are key-value pairs stored by a script in a persistent store. Script Properties are scoped per script, regardless of which user runs the script.

MethodReturn typeBrief description
deleteAllProperties()ScriptPropertiesDeletes all properties.
deleteProperty(key)ScriptPropertiesDeletes 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)ScriptPropertiesBulk-sets all the properties drawn from the given object.
setProperties(properties, deleteAllOthers)ScriptPropertiesBulk-sets all the properties drawn from the given object.
setProperty(key, value)ScriptPropertiesPersists the specified in value with the provided key.

Deprecated methods

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

Deletes all properties.

ScriptProperties.deleteAllProperties();

Return

ScriptProperties — this object, for chaining

See also


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

Deletes the property with the given key.

ScriptProperties.deleteProperty('special');

Parameters

NameTypeDescription
keyStringkey for property to delete

Return

ScriptProperties — this object, for chaining

See also


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

Get all of the available keys.

Return

String[]


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't update them in storage and vice versa.

ScriptProperties.setProperties({
  "cow"     : "moo",
  "sheep"   : "baa",
  "chicken" : "cluck"
});

// Logs "A cow goes: moo"
Logger.log("A cow goes: %s", ScriptProperties.getProperty("cow"));

// This makes a copy. Any changes that happen here will not
// be written back to properties.
var animalSounds = ScriptProperties.getProperties();

// Logs:
// A chicken goes cluck!
// A cow goes moo!
// A sheep goes baa!
for(var kind in animalSounds) {
  Logger.log("A %s goes %s!", kind, animalSounds[kind]);
}

Return

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


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.

const specialValue = ScriptProperties.getProperty('special');

Parameters

NameTypeDescription
keyStringkey for the value to retrieve

Return

String — the value associated with the key

See also


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

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

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

Parameters

NameTypeDescription
propertiesObjectan object containing the properties to set.

Return

ScriptProperties — this object, for chaining

See also


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 properties
ScriptProperties.setProperties({special: 'sauce', 'meaning': 42}, true);

Parameters

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

Return

ScriptProperties — this object, for chaining

See also


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 this key will be overwritten.

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

Parameters

NameTypeDescription
keyStringkey for property
valueStringvalue to associate with the key

Return

ScriptProperties — this object, for chaining

See also