Class PropertiesService
プロパティサービススクリプトでは、1 つのスクリプト、1 人のスクリプト ユーザー、またはアドオンが使用されている 1 つのドキュメントにスコープされた Key-Value ペア形式のシンプルなデータを保存できます。プロパティはスクリプト間で共有できません。各タイプのプロパティを使用するタイミングの詳細については、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()
開いているドキュメント、スプレッドシート、フォーム内ですべてのユーザーがアクセスできるプロパティ ストア(このスクリプトのみ)を取得します。スクリプトが公開され、アドオンとして実行されている場合、または Google ファイル形式にバインドされている場合にのみ使用できます。ドキュメント プロパティが使用できない場合、このメソッドは null
を返します。スクリプトによって作成されたドキュメント プロパティには、同じドキュメントにアクセスしている他のスクリプトでも、そのスクリプト外からアクセスすることはできません。
戻る
Properties
- このスクリプト専用のプロパティ ストア。現在のドキュメントのすべてのユーザーがアクセスできます。スクリプトがアドオンでないか、Google Workspace ファイルにバインドされていない場合は null
です。
getScriptProperties()
すべてのユーザーがアクセスできるプロパティ ストアを取得します(ただし、このスクリプト内のみ)。
戻る
Properties
- スクリプトのすべてのユーザーがアクセスできるプロパティ ストア
getUserProperties()
現在のユーザーのみが、このスクリプト内からアクセスできるプロパティ ストアを取得します。
戻る
Properties
- スクリプトの現在のユーザーのみがアクセスできるプロパティ ストア
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-12-22 UTC。
[null,null,["最終更新日 2024-12-22 UTC。"],[[["The Properties Service lets Apps Script store simple data as key-value pairs, with different scopes for scripts, users, and documents."],["It offers three methods to access properties: `getDocumentProperties()`, `getScriptProperties()`, and `getUserProperties()`."],["`getDocumentProperties()` provides property storage accessible to all users within a specific document, spreadsheet, or form where the script is running."],["`getScriptProperties()` allows storing properties accessible to all users, but only within the context of the current script."],["`getUserProperties()` provides a property store specific to the current user and accessible only within the current script."]]],["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"]]