Object reference
Properties
Properties store key and value text pairs between runs with getProperty() and setProperty(). 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)
This saves one key and value pair to script properties, then reads it back. It only changes that one key.
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
This lists the key names currently saved in script properties and does not change any of them.
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)
This deletes a single key from script properties. Every other saved key is left in place.
PropertiesService.PropertiesShow example code
function deleteLastRunProperty() {
const properties = PropertiesService.getScriptProperties();
properties.deleteProperty('lastRunDate');
Logger.log('Deleted lastRunDate.');
} Technical reference
Exact names and signatures
Generated runtime and signature facts stay separate from the beginner actions above. Open method details only 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