Class PropertiesService
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
प्रॉपर्टीसेवा
इसकी मदद से, स्क्रिप्ट में की-वैल्यू पेयर में आसान डेटा स्टोर किया जा सकता है. यह डेटा, किसी एक स्क्रिप्ट, स्क्रिप्ट के किसी एक उपयोगकर्ता या उस दस्तावेज़ के दायरे में होता है जिसमें ऐड-ऑन का इस्तेमाल किया जाता है. प्रॉपर्टी को स्क्रिप्ट के बीच शेयर नहीं किया जा सकता.
हर तरह की प्रॉपर्टी का इस्तेमाल कब करना है, इस बारे में ज़्यादा जानने के लिए, Properties सेवा की गाइड देखें.
// Sets three properties of different types.
const documentProperties = PropertiesService.getDocumentProperties();
const scriptProperties = PropertiesService.getScriptProperties();
const userProperties = PropertiesService.getUserProperties();
documentProperties.setProperty('DAYS_TO_FETCH', '5');
scriptProperties.setProperty(
'SERVER_URL',
'http://www.example.com/MyWeatherService/',
);
userProperties.setProperty('DISPLAY_UNITS', 'metric');
तरीके
तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
getDocumentProperties() | Properties | सिर्फ़ इस स्क्रिप्ट के लिए, एक प्रॉपर्टी स्टोर मिलता है. सभी उपयोगकर्ता, खुले दस्तावेज़, स्प्रेडशीट या फ़ॉर्म में इसे ऐक्सेस कर सकते हैं. |
getScriptProperties() | Properties | एक प्रॉपर्टी स्टोर मिलता है जिसे सभी उपयोगकर्ता ऐक्सेस कर सकते हैं, लेकिन सिर्फ़ इस स्क्रिप्ट में. |
getUserProperties() | Properties | एक प्रॉपर्टी स्टोर मिलता है जिसे सिर्फ़ मौजूदा उपयोगकर्ता ऐक्सेस कर सकता है. साथ ही, उसे सिर्फ़ इस स्क्रिप्ट में ऐक्सेस किया जा सकता है. |
ज़्यादा जानकारी वाला दस्तावेज़
getDocumentProperties()
सिर्फ़ इस स्क्रिप्ट के लिए, एक प्रॉपर्टी स्टोर मिलता है. सभी उपयोगकर्ता, खुले दस्तावेज़, स्प्रेडशीट या फ़ॉर्म में इसे ऐक्सेस कर सकते हैं. यह विकल्प सिर्फ़ तब उपलब्ध होता है, जब स्क्रिप्ट को पब्लिश किया गया हो और वह ऐड-ऑन के तौर पर काम कर रही हो. इसके अलावा, यह विकल्प तब भी उपलब्ध होता है, जब स्क्रिप्ट को Google के किसी फ़ाइल टाइप से बाउंड किया गया हो. दस्तावेज़ की प्रॉपर्टी उपलब्ध न होने पर, यह तरीका null
दिखाता है. किसी स्क्रिप्ट से बनाई गई दस्तावेज़ प्रॉपर्टी, उस स्क्रिप्ट के बाहर ऐक्सेस नहीं की जा सकतीं. भले ही, वे उसी दस्तावेज़ को ऐक्सेस करने वाली अन्य स्क्रिप्ट हों.
वापसी का टिकट
Properties
— सिर्फ़ इस स्क्रिप्ट के लिए एक प्रॉपर्टी स्टोर, जिसे मौजूदा दस्तावेज़ के सभी उपयोगकर्ता ऐक्सेस कर सकते हैं या null
, अगर स्क्रिप्ट कोई ऐड-ऑन नहीं है या Google Workspace फ़ाइल से बंधी नहीं है
getScriptProperties()
एक प्रॉपर्टी स्टोर मिलता है जिसे सभी उपयोगकर्ता ऐक्सेस कर सकते हैं, लेकिन सिर्फ़ इस स्क्रिप्ट में.
वापसी का टिकट
Properties
— एक प्रॉपर्टी स्टोर, जिसे स्क्रिप्ट के सभी उपयोगकर्ता ऐक्सेस कर सकते हैं
getUserProperties()
एक प्रॉपर्टी स्टोर मिलता है जिसे सिर्फ़ मौजूदा उपयोगकर्ता ऐक्सेस कर सकता है. साथ ही, उसे सिर्फ़ इस स्क्रिप्ट में ऐक्सेस किया जा सकता है.
वापसी का टिकट
Properties
— एक प्रॉपर्टी स्टोर, जिसे सिर्फ़ स्क्रिप्ट का मौजूदा उपयोगकर्ता ऐक्सेस कर सकता है
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThe Properties Service lets Apps Script store simple data as key-value pairs, with different scopes for scripts, users, and documents.\u003c/p\u003e\n"],["\u003cp\u003eIt offers three methods to access properties: \u003ccode\u003egetDocumentProperties()\u003c/code\u003e, \u003ccode\u003egetScriptProperties()\u003c/code\u003e, and \u003ccode\u003egetUserProperties()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetDocumentProperties()\u003c/code\u003e provides property storage accessible to all users within a specific document, spreadsheet, or form where the script is running.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetScriptProperties()\u003c/code\u003e allows storing properties accessible to all users, but only within the context of the current script.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetUserProperties()\u003c/code\u003e provides a property store specific to the current user and accessible only within the current script.\u003c/p\u003e\n"]]],["The `PropertiesService` stores data in key-value pairs, accessible via `getDocumentProperties`, `getScriptProperties`, and `getUserProperties`. `getDocumentProperties` stores data within a specific document, accessible to all users. `getScriptProperties` stores data within a script, accessible to all users. `getUserProperties` stores data for a single user within a script. The example code demonstrates setting properties using each method: `setProperty`. Each method returns a `Properties` object, which is a property store.\n"],null,["# Class PropertiesService\n\nPropertiesService\n\nAllows scripts to store simple data in key-value pairs scoped to one script, one user of a\nscript, or one document in which an add-on is used. Properties cannot be shared between scripts.\nFor more information about when to use each type of property, see the [guide to the Properties service](/apps-script/guides/properties).\n\n```javascript\n// Sets three properties of different types.\nconst documentProperties = PropertiesService.getDocumentProperties();\nconst scriptProperties = PropertiesService.getScriptProperties();\nconst userProperties = PropertiesService.getUserProperties();\n\ndocumentProperties.setProperty('DAYS_TO_FETCH', '5');\nscriptProperties.setProperty(\n 'SERVER_URL',\n 'http://www.example.com/MyWeatherService/',\n);\nuserProperties.setProperty('DISPLAY_UNITS', 'metric');\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|\n| [getDocumentProperties()](#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()](#getScriptProperties()) | [Properties](/apps-script/reference/properties/properties) | Gets a property store that all users can access, but only within this script. |\n| [getUserProperties()](#getUserProperties()) | [Properties](/apps-script/reference/properties/properties) | Gets a property store that only the current user can access, and only within this script. |\n\nDetailed documentation\n----------------------\n\n### `get``Document``Properties()`\n\nGets a property store (for this script only) that all users can access within the open\ndocument, spreadsheet, or form. It is only available if the script is published and executing\nas an add-on or if it is [bound](https://developers.google.com/apps-script/scripts_containers) to a Google file\ntype. When document properties are not available this method returns `null`. Document\nproperties created by a script are not accessible outside that script, even by other scripts\naccessing the same document.\n\n#### Return\n\n\n[Properties](/apps-script/reference/properties/properties) --- a property store for this script only that all users of the current document can\naccess, or `null` if the script is not either an add-on or bound to a Google\nWorkspace file\n\n*** ** * ** ***\n\n### `get``Script``Properties()`\n\nGets a property store that all users can access, but only within this script.\n\n#### Return\n\n\n[Properties](/apps-script/reference/properties/properties) --- a property store that all users of the script can access\n\n*** ** * ** ***\n\n### `get``User``Properties()`\n\nGets a property store that only the current user can access, and only within this script.\n\n#### Return\n\n\n[Properties](/apps-script/reference/properties/properties) --- a property store that only the current user of the script can access"]]