Object reference
Properties
Properties store text values under names you choose, called keys, and keep them between runs. Use getProperty() and setProperty() to read and save them. PropertiesService.getScriptProperties() is shared across the project, user properties are per-person, and document properties are per-file.
PropertiesService.PropertiesStart here
Get this object first
Get the script properties store. It is the one most guides use, since its values are the same for everyone who runs the script.
function showScriptPropertyKeys() {
const properties = PropertiesService.getScriptProperties();
Logger.log(properties.getKeys());
} Then use it
Common actions
Choose an action, then open its example only when you need the code.
Set and read a property (this saves a value)
Saves one key and its value to script properties, then reads it back. Other saved keys are not changed.
PropertiesService.PropertiesShow example code
function setAndReadLastRunProperty() {
const properties = PropertiesService.getScriptProperties();
properties.setProperty('lastRunDate', new Date().toISOString());
Logger.log(properties.getProperty('lastRunDate'));
} List every saved key
Logs the names of the keys saved in script properties.
PropertiesService.PropertiesShow example code
function logAllScriptPropertyKeys() {
const properties = PropertiesService.getScriptProperties();
const keys = properties.getKeys();
Logger.log(keys.join(', ') || 'No properties saved');
} Delete one property (this removes a saved value)
Deletes one key from script properties. Other saved keys are not changed.
PropertiesService.PropertiesShow example code
function deleteLastRunProperty() {
const properties = PropertiesService.getScriptProperties();
properties.deleteProperty('lastRunDate');
Logger.log('Deleted lastRunDate.');
} Technical reference
Exact names and signatures
Open method details when you need them.
At a glance
- Service
- PropertiesService
- Reference symbol
PropertiesService.Properties- Object
Properties- Runtime
- From signature data
Methods and signatures
Browse 7 methods
deleteAllProperties
- deleteAllProperties(): PropertiesService.Properties
deleteProperty
- deleteProperty(key: string): PropertiesService.Properties
getKeys
- getKeys(): string[]
getProperties
- getProperties(): { [key: string]: string }
getProperty
- getProperty(key: string): string | null
setProperties
- setProperties(properties: { [key: string]: string }): PropertiesService.Properties
- setProperties(properties: { [key: string]: string }, deleteAllOthers: boolean): PropertiesService.Properties
setProperty
- setProperty(key: string, value: string): PropertiesService.Properties
Need the whole workflow?
Return to a task guide
Task guides cover setup, permissions, expected results, and troubleshooting as well as object methods.
Browse Script utilities tasks