Properties Service
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Proprietà
Questo servizio consente agli script di memorizzare le stringhe come coppie chiave/valore con ambito limitato a un script, a un utente di uno script o a un documento in cui viene utilizzato un componente aggiuntivo dell'editor.
Per saperne di più su quando utilizzare ciascun tipo di proprietà, consulta la
guida al servizio Properties.
Corsi
Nome | Breve descrizione |
Properties | L'oggetto properties funge da interfaccia per accedere alle proprietà utente, del documento o dello script. |
PropertiesService | Consente agli script di memorizzare dati semplici in coppie chiave/valore limitate a uno script, a un utente di uno script o a un documento in cui viene utilizzato un componente aggiuntivo. |
ScriptProperties
| Le proprietà script sono coppie chiave-valore memorizzate da uno script in un archivio permanente. |
UserProperties
| Le proprietà utente sono coppie chiave/valore univoche per un utente. |
Metodi
Metodo | Tipo restituito | Breve descrizione |
getDocumentProperties() | Properties | Recupera un archivio di proprietà (solo per questo script) a cui tutti gli utenti possono accedere all'interno del documento, del foglio di lavoro o del modulo aperto. |
getScriptProperties() | Properties | Recupera un archivio delle proprietà a cui tutti gli utenti possono accedere, ma solo all'interno di questo script. |
getUserProperties() | Properties | Recupera un archivio delle proprietà a cui solo l'utente corrente può accedere e solo all'interno di questo script. |
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-26 UTC.
[null,null,["Ultimo aggiornamento 2025-07-26 UTC."],[[["\u003cp\u003eThe Properties Service allows scripts to store data as key-value pairs, with different scopes available: script, user, or document.\u003c/p\u003e\n"],["\u003cp\u003eThis service offers classes for managing properties like Properties, PropertiesService, ScriptProperties, and UserProperties, each with its own specific purpose.\u003c/p\u003e\n"],["\u003cp\u003eProperties can be manipulated with methods such as deleting, retrieving by key or in bulk, and setting new values.\u003c/p\u003e\n"],["\u003cp\u003eDifferent property stores can be accessed, including document-specific, script-wide, or user-specific stores, through the PropertiesService class.\u003c/p\u003e\n"]]],[],null,["# Properties Service\n\nProperties\n\nThis service allows scripts to store strings as key-value pairs scoped to\none script, one user of a script, or one document in which an\n[editor add-on](/gsuite/add-ons/concepts/types#editor_add-ons) is used.\nFor more information about when to use each type of property, see the\n[guide to the Properties service](/apps-script/guides/properties).\n\nClasses\n-------\n\n| Name | Brief description |\n|---------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Properties](/apps-script/reference/properties/properties) | The properties object acts as the interface to access user, document, or script properties. |\n| [PropertiesService](/apps-script/reference/properties/properties-service) | Allows scripts to store simple data in key-value pairs scoped to one script, one user of a script, or one document in which an add-on is used. |\n| [ScriptProperties](/apps-script/reference/properties/script-properties) | Script Properties are key-value pairs stored by a script in a persistent store. |\n| [UserProperties](/apps-script/reference/properties/user-properties) | User Properties are key-value pairs unique to a user. |\n\n[Properties](/apps-script/reference/properties/properties)\n----------------------------------------------------------\n\n### Methods\n\n| Method | Return type | Brief description |\n|--------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|\n| [deleteAllProperties()](/apps-script/reference/properties/properties#deleteAllProperties()) | [Properties](/apps-script/reference/properties/properties) | Deletes all properties in the current `Properties` store. |\n| [deleteProperty(key)](/apps-script/reference/properties/properties#deleteProperty(String)) | [Properties](/apps-script/reference/properties/properties) | Deletes the property with the given key in the current `Properties` store. |\n| [getKeys()](/apps-script/reference/properties/properties#getKeys()) | `String[]` | Gets all keys in the current `Properties` store. |\n| [getProperties()](/apps-script/reference/properties/properties#getProperties()) | `Object` | Gets a copy of all key-value pairs in the current `Properties` store. |\n| [getProperty(key)](/apps-script/reference/properties/properties#getProperty(String)) | `String` | Gets the value associated with the given key in the current `Properties` store, or `null` if no such key exists. |\n| [setProperties(properties)](/apps-script/reference/properties/properties#setProperties(Object)) | [Properties](/apps-script/reference/properties/properties) | Sets all key-value pairs from the given object in the current `Properties` store. |\n| [setProperties(properties, deleteAllOthers)](/apps-script/reference/properties/properties#setProperties(Object,Boolean)) | [Properties](/apps-script/reference/properties/properties) | Sets all key-value pairs from the given object in the current `Properties` store, optionally deleting all other properties in the store. |\n| [setProperty(key, value)](/apps-script/reference/properties/properties#setProperty(String,String)) | [Properties](/apps-script/reference/properties/properties) | Sets the given key-value pair in the current `Properties` store. |\n\n[PropertiesService](/apps-script/reference/properties/properties-service)\n-------------------------------------------------------------------------\n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------------------------------------------------------------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|\n| [getDocumentProperties()](/apps-script/reference/properties/properties-service#getDocumentProperties()) | [Properties](/apps-script/reference/properties/properties) | Gets a property store (for this script only) that all users can access within the open document, spreadsheet, or form. |\n| [getScriptProperties()](/apps-script/reference/properties/properties-service#getScriptProperties()) | [Properties](/apps-script/reference/properties/properties) | Gets a property store that all users can access, but only within this script. |\n| [getUserProperties()](/apps-script/reference/properties/properties-service#getUserProperties()) | [Properties](/apps-script/reference/properties/properties) | Gets a property store that only the current user can access, and only within this script. |\n\n[ScriptProperties](/apps-script/reference/properties/script-properties)\n-----------------------------------------------------------------------\n\n[UserProperties](/apps-script/reference/properties/user-properties)\n-------------------------------------------------------------------"]]