Skip to content

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.Properties

Start 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.

Code.gs
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.Properties
Show example code
Code.gs
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.Properties
Show example code
Code.gs
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.Properties
Show example code
Code.gs
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

From signature data Google source
  • deleteAllProperties(): PropertiesService.Properties

deleteProperty

From signature data Google source
  • deleteProperty(key: string): PropertiesService.Properties

getKeys

From signature data Google source
  • getKeys(): string[]

getProperties

From signature data Google source
  • getProperties(): { [key: string]: string }

getProperty

From signature data Google source
  • getProperty(key: string): string | null

setProperties

From signature data Google source
  • setProperties(properties: { [key: string]: string }): PropertiesService.Properties
  • setProperties(properties: { [key: string]: string }, deleteAllOthers: boolean): PropertiesService.Properties

setProperty

From signature data Google source
  • 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