يعمل عنصر "الخصائص" كواجهة للوصول إلى خصائص المستخدِم أو المستند أو النص البرمجي. يعتمد نوع
السمة المحدّد على إحدى الطرق الثلاث لProperties
النص البرمجي المُستخدَم: Properties
أو Properties
أو Properties
.
لا يمكن مشاركة الخصائص بين النصوص البرمجية. لمزيد من المعلومات عن أنواع المواقع، اطّلِع على
دليل خدمة "السمات".
الطُرق
الطريقة | نوع القيمة التي يتم عرضها | وصف قصير |
---|---|---|
delete | Properties | لحذف جميع المواقع في متجر Properties الحالي |
delete | Properties | تؤدي هذه الوظيفة إلى حذف الموقع الذي يحتوي على المفتاح المحدّد في متجر Properties الحالي. |
get | String[] | تحصل على جميع المفاتيح في متجر Properties الحالي. |
get | Object | تحصل على نسخة من جميع أزواج المفتاح/القيمة في متجر Properties الحالي. |
get | String | تحصل على القيمة المرتبطة بالمفتاح المحدَّد في متجر Properties الحالي، أو null إذا لم يكن هناك مفتاح من هذا النوع. |
set | Properties | تُستخدَم لضبط جميع أزواج المفتاح/القيمة من العنصر المحدّد في ذاكرة التخزين Properties الحالية. |
set | Properties | تُستخدَم لضبط جميع أزواج المفتاح/القيمة من العنصر المحدّد في متجر Properties الحالي،
وحذف جميع السمات الأخرى في المتجر اختياريًا. |
set | Properties | تُستخدَم لضبط زوج المفتاح/القيمة المحدَّد في متجر Properties الحالي. |
مستندات تفصيلية
delete All Properties()
لحذف جميع المواقع في متجر Properties
الحالي
// Deletes all user properties. const userProperties = PropertiesService.getUserProperties(); userProperties.deleteAllProperties();
الإرجاع
Properties
- متجر Properties
هذا، لتسلسله
delete Property(key)
تؤدي هذه الوظيفة إلى حذف الموقع الذي يحتوي على المفتاح المحدّد في متجر Properties
الحالي.
// Deletes the user property 'nickname'. const userProperties = PropertiesService.getUserProperties(); userProperties.deleteProperty('nickname');
المعلمات
الاسم | النوع | الوصف |
---|---|---|
key | String | مفتاح الموقع المطلوب حذفه |
الإرجاع
Properties
- متجر Properties
هذا، لتسلسله
get Keys()
تحصل على جميع المفاتيح في متجر Properties
الحالي.
// Sets several properties, then logs the value of each key. const scriptProperties = PropertiesService.getScriptProperties(); scriptProperties.setProperties({ cow: 'moo', sheep: 'baa', chicken: 'cluck', }); const keys = scriptProperties.getKeys(); Logger.log('Animals known:'); for (let i = 0; i < keys.length; i++) { Logger.log(keys[i]); }
الإرجاع
String[]
: صفيف يضمّ جميع المفاتيح في متجر Properties
الحالي
get Properties()
تحصل على نسخة من جميع أزواج المفتاح/القيمة في متجر Properties
الحالي. يُرجى العلم أنّ
العنصر الذي تم إرجاعه ليس عرضًا مباشرًا للمتجر. نتيجةً لذلك، لن يؤدي تغيير السمات في
الكائن الذي تم إرجاعه إلى تعديلها تلقائيًا في مساحة التخزين، أو العكس.
// Sets several script properties, then retrieves them and logs them. const scriptProperties = PropertiesService.getScriptProperties(); scriptProperties.setProperties({ cow: 'moo', sheep: 'baa', chicken: 'cluck', }); const animalSounds = scriptProperties.getProperties(); // Logs: // A chicken goes cluck! // A cow goes moo! // A sheep goes baa! for (const kind in animalSounds) { Logger.log('A %s goes %s!', kind, animalSounds[kind]); }
الإرجاع
Object
: نسخة من جميع أزواج المفتاح/القيمة في متجر Properties
الحالي
get Property(key)
تحصل على القيمة المرتبطة بالمفتاح المحدَّد في متجر Properties
الحالي، أو null
إذا لم يكن هناك مفتاح من هذا النوع.
// Gets the user property 'nickname'. const userProperties = PropertiesService.getUserProperties(); const nickname = userProperties.getProperty('nickname'); Logger.log(nickname);
المعلمات
الاسم | النوع | الوصف |
---|---|---|
key | String | مفتاح قيمة السمة المطلوب استرجاعها |
الإرجاع
String
: القيمة المرتبطة بالمفتاح المحدّد في متجر Properties
الحالي
set Properties(properties)
تُستخدَم لضبط جميع أزواج المفتاح/القيمة من العنصر المحدّد في ذاكرة التخزين Properties
الحالية.
// Sets multiple user properties at once. const userProperties = PropertiesService.getUserProperties(); const newProperties = { nickname: 'Bob', region: 'US', language: 'EN' }; userProperties.setProperties(newProperties);
المعلمات
الاسم | النوع | الوصف |
---|---|---|
properties | Object | عنصر يحتوي على أزواج مفاتيح/قيم لضبطها |
الإرجاع
Properties
- متجر Properties
هذا، لتسلسله
set Properties(properties, deleteAllOthers)
تُستخدَم لضبط جميع أزواج المفتاح/القيمة من العنصر المحدّد في متجر Properties
الحالي،
وحذف جميع السمات الأخرى في المتجر اختياريًا.
// Sets multiple user properties at once while deleting all other user // properties. const userProperties = PropertiesService.getUserProperties(); const newProperties = { nickname: 'Bob', region: 'US', language: 'EN' }; userProperties.setProperties(newProperties, true);
المعلمات
الاسم | النوع | الوصف |
---|---|---|
properties | Object | عنصر يحتوي على أزواج مفاتيح/قيم لضبطها |
delete | Boolean | true لحذف جميع أزواج المفتاح/القيمة الأخرى في عنصر
المواقع، false لحذف |
الإرجاع
Properties
- متجر Properties
هذا، لتسلسله
set Property(key, value)
تُستخدَم لضبط زوج المفتاح/القيمة المحدَّد في متجر Properties
الحالي.
// Sets the user property 'nickname' to 'Bobby'. const userProperties = PropertiesService.getUserProperties(); userProperties.setProperty('nickname', 'Bobby');
المعلمات
الاسم | النوع | الوصف |
---|---|---|
key | String | مفتاح الموقع |
value | String | القيمة المطلوب ربطها بالمفتاح |
الإرجاع
Properties
- متجر Properties
هذا، لتسلسله