Class UserProperties

使用者屬性

已淘汰。這個類別已淘汰,不應在新的指令碼中使用。

使用者屬性是使用者專屬的鍵/值組合。使用者屬性會依使用者設定範圍,任何以使用者身分執行的程式碼,只能存取該使用者的使用者屬性。

方法傳回類型簡短說明
deleteAllProperties()UserProperties刪除所有資源。
deleteProperty(key)UserProperties刪除指定鍵的屬性。
getKeys()String[]取得所有可用的鍵。
getProperties()Object一次取得所有可用的資源。
getProperty(key)String傳回與提供的鍵相關聯的值,如果沒有此類值,則傳回空值。
setProperties(properties)UserProperties從指定物件繪製的所有屬性,以大量方式設定。
setProperties(properties, deleteAllOthers)UserProperties從指定物件繪製的所有屬性,以大量方式設定。
setProperty(key, value)UserProperties使用提供的鍵,將指定的 in 值儲存起來。

已淘汰的方法

已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

刪除所有資源。

UserProperties.deleteAllProperties();

回攻員

UserProperties:這個物件,用於鏈結

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

刪除指定鍵的屬性。

UserProperties.deleteProperty('special');

參數

名稱類型說明
keyString要刪除的資源鍵

回攻員

UserProperties:這個物件,用於鏈結

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

取得所有可用的鍵。

回攻員

String[]


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

一次取得所有可用的資源。

這會提供副本,而非即時檢視畫面,因此變更已回傳物件的屬性不會更新儲存空間中的屬性,反之亦然。

UserProperties.setProperties({
  "cow"     : "moo",
  "sheep"   : "baa",
  "chicken" : "cluck"
});

// Logs "A cow goes: moo"
Logger.log("A cow goes: %s", UserProperties.getProperty("cow"));

// This makes a copy. Any changes that happen here will not
// be written back to properties.
var animalSounds = UserProperties.getProperties();

// Logs:
// A chicken goes cluck!
// A cow goes moo!
// A sheep goes baa!
for(var kind in animalSounds) {
  Logger.log("A %s goes %s!", kind, animalSounds[kind]);
}

回攻員

Object:包含鍵/值組合的屬性副本


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

傳回與提供的鍵相關聯的值,如果沒有此類值,則傳回空值。

const specialValue = UserProperties.getProperty('special');

參數

名稱類型說明
keyString要擷取的值的鍵

回攻員

String:與鍵相關聯的值

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

大量設定從指定物件繪製的所有屬性。

UserProperties.setProperties({special: 'sauce', 'meaning': 42});

參數

名稱類型說明
propertiesObject包含要設定的屬性的物件。

回攻員

UserProperties:這個物件,用於鏈結

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

大量設定從指定物件繪製的所有屬性。

// This deletes all other properties
UserProperties.setProperties({special: 'sauce', 'meaning': 42}, true);

參數

名稱類型說明
propertiesObject包含要設定的屬性的物件。
deleteAllOthersBoolean是否要刪除所有現有資源。

回攻員

UserProperties:這個物件,用於鏈結

另請參閱


已淘汰。這個函式已淘汰,不建議在新指令碼中使用。

使用提供的鍵將指定的值儲存。系統會覆寫與此鍵相關聯的任何現有值。

UserProperties.setProperty('special', 'sauce');

參數

名稱類型說明
keyString屬性鍵
valueString要與鍵建立關聯的值

回攻員

UserProperties:這個物件,用於鏈結

另請參閱