SettingsService works similarly to PropertiesService but with enhanced capabilities.
The current modification reduces the load on system limits when reading and writing properties. This is achieved through parallel data storage in CacheService.
Note! Using this service may increase script execution time.
- Open your project in the Google Apps Script Dashboard.
- Copy the contents of the settings.js file and paste it into a new file in your Google Apps Script project.
For detailed documentation, please visit the Wiki page.
Retrieve settings for a document, script, or user:
// Document settings
const documentSettings = SettingsService.getDocumentSettings();
// Script settings
const scriptSettings = SettingsService.getScriptSettings();
// User settings
const userSettings = SettingsService.getUserSettings();
Use methods or proxies to save data:
// Using the method
scriptSettings.setProperty('email', '[email protected]');
// Using a proxy
scriptSettings.email = '[email protected]';
Use methods or proxies to retrieve data:
// Using the method
const email = scriptSettings.getProperty('email');
// Using a proxy
const email = scriptSettings.email;
- Create a method
settings.setProperties(properties, deleteAllOthers)
. - Create a method
settings.getKeys()
. - Create method
settings.getProperties()
. - Create a method
settings.deleteAllProperties()
. - Use a recursive proxy to track changes to the object tree in
settings._values
, this should also create a hierarchy of objects, e.g.:settings._values.prop1.m1.m2 = 5;
.
Please read CONTRIBUTING.md for details on how to contribute to this project.
Please refer to CHANGELOG.md for a detailed list of changes and updates.
This project is licensed under the LICENSE.md file.