Class ScriptProperties

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

  • Script Properties store key-value pairs persistently for a script, independent of the user running it.

  • Deprecated methods include functions to delete, get, and set properties.

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.

Deprecated methods

MethodReturn typeBrief description
(削除) deleteAllProperties() (削除ここまで)(削除) ScriptProperties (削除ここまで)Deletes all properties.
(削除) deleteProperty(key) (削除ここまで)(削除) ScriptProperties (削除ここまで)Deletes 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) (削除ここまで)(削除) ScriptProperties (削除ここまで)Bulk-sets all the properties drawn from the given object.
(削除) setProperties(properties, deleteAllOthers) (削除ここまで)(削除) ScriptProperties (削除ここまで)Bulk-sets all the properties drawn from the given object.
(削除) setProperty(key, value) (削除ここまで)(削除) ScriptProperties (削除ここまで)Persists 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.

ScriptProperties.deleteAllProperties();

Return

(削除) ScriptProperties (削除ここまで) — 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.

ScriptProperties.deleteProperty('special');

Parameters

NameTypeDescription
keyStringkey for property to delete

Return

(削除) ScriptProperties (削除ここまで) — 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'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.
varanimalSounds=ScriptProperties.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=ScriptProperties.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.

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

Parameters

NameTypeDescription
propertiesObjectan object containing the properties to set.

Return

(削除) ScriptProperties (削除ここまで) — 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 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


(削除) 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 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

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 2024年12月02日 UTC.