Skip to content

Instantly share code, notes, and snippets.

@onesword0618
Last active August 14, 2019 03:28
Show Gist options
  • Select an option

  • Save onesword0618/bc2e212088bb2e1ae7a889ba75a5b43f to your computer and use it in GitHub Desktop.

Select an option

Save onesword0618/bc2e212088bb2e1ae7a889ba75a5b43f to your computer and use it in GitHub Desktop.
設定情報を登録する
/*
key-value形式で管理する設定情報を扱うクラス
全てのユーザーがアクセスできるプロパティストアを扱う
*/
function Property () {
// クラス内使いまわすためにPropertiesService.getScriptProperties()の呼び出し結果を保存
this.service = PropertiesService.getScriptProperties()
/*
設定情報を設定する関数
ex) new Property().setProperty("APP_FOLDER","123456789qwertyuiiasdfghjj")
*/
this.setProperty = function (key, value) {
this.service.setProperty(key, value)
}
/*
設定情報を取り出す関数
呼び出すときはKeyを指定することでvalueを呼び出せる
存在しないkey値を設定した場合はnullが返る
ex)
var prop = new Property()
moveFileFromRootToFolder(prop.getProperty("FORM_ID"), prop.getProperty("APP_FOLDER"))
*/
this.getProperty = function (key) {
return this.service.getProperty(key)
}
/*
設定情報を削除する関数
指定したkey値とそのペアのvalueを削除する
ex) new Property().deleteProperty("APP_FOLDER")
*/
this.deleteProperty = function (key) {
this.service.deleteProperty(key)
}
/*
設定情報を全て削除する関数
プロパティストアで管理している情報を削除する
ex) new Property().deleteAllProperties()
*/
this.deleteAllProperties = function () {
PropertiesService.getScriptProperties().deleteAllProperties()
}
}
@onesword0618
Copy link
Copy Markdown
Author

onesword0618 commented Aug 13, 2019

複数のkey値を取り扱う機能があるが、着手しているプロジェクトでは要件に含まれていないので未実装

参照リファレンス
Properties

注意事項
現時点(2019.08.14)では下記のclassは非推奨
ScriptProperties
UserProperties

@onesword0618
Copy link
Copy Markdown
Author

クラス化を試みる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment