Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScriptProperties & UserProperties had been deprecated

The documentation for the PropertiesService lists both, the ScriptProperties and UserProperties as:

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

... while the DocumentProperties seem to have no page in the documentation.

Q: is there any suitable replacement for these classes, in order to use them in new scripts?

like image 766
Martin Zeitler Avatar asked Mar 02 '26 08:03

Martin Zeitler


1 Answers

The replacement for the deprecated classes is the class Properties.

PropertiesService has three methods getDocumentProperties(), getScriptProperties(), and getUserProperties(). Perhaps once upon a time these returned objects of those deprecated classes; but now they all return an object of class Properties.

Script properties, user properties, and document properties remain available and they are non-deprecated; it's just that the classes have been unified into Properties.

var sp = PropertiesService.getScriptProperties();
sp.setProperty("foo", "bar");
var up = PropertiesService.getUserProperties();
up.setProperty("foo", "baz");
var dp = PropertiesService.getDocumentProperties();
dp.setProperty("foo", "blargh");
Logger.log([sp.getProperty("foo"), up.getProperty("foo"), dp.getProperty("foo")]);

logs [bar, baz, blargh].


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!