Last active
August 14, 2019 03:28
-
-
Save onesword0618/bc2e212088bb2e1ae7a889ba75a5b43f to your computer and use it in GitHub Desktop.
設定情報を登録する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 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() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
複数のkey値を取り扱う機能があるが、着手しているプロジェクトでは要件に含まれていないので未実装
参照リファレンス
Properties
注意事項
現時点(2019.08.14)では下記のclassは非推奨
ScriptProperties
UserProperties