Google ドライブのファイルに関連付けられているユーザー。ユーザーには、File.getEditors()
メソッドや Folder.getViewers()
メソッドなどからアクセスできます。
// Log the email address of all users who have edit access to a file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getEmail()); }
メソッド
メソッド | 戻り値の型 | 概要 |
---|---|---|
get | String | ユーザーのアカウントに関連付けられているドメイン名を取得します。 |
get | String | ユーザーのメールアドレスを取得します。 |
get | String | ユーザーの名前を取得します。 |
get | String | ユーザーの写真の URL を取得します。 |
サポート終了のメソッド
メソッド | 戻り値の型 | 概要 |
---|---|---|
| String | ユーザーのメールアドレスを取得します。 |
詳細なドキュメント
getDomain()
ユーザーのアカウントに関連付けられているドメイン名を取得します。
// Log the domain names associated with all users who have edit access to a // file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getDomain()); }
戻る
String
- ユーザーのアカウントに関連付けられているドメイン名
getEmail()
ユーザーのメールアドレスを取得します。ユーザーのメールアドレスは、ユーザーが Google+ アカウントの設定ページでアドレスの共有を選択した場合、またはユーザーがスクリプトを実行しているユーザーと同じドメインに属し、ドメイン管理者がドメイン内のすべてのユーザーが他のユーザーのメールアドレスを閲覧できるように許可している場合にのみ使用できます。
// Log the email address of all users who have edit access to a file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getEmail()); }
戻る
String
- ユーザーのメールアドレス。メールアドレスが使用できない場合は空の文字列
getName()
ユーザーの名前を取得します。ユーザーの名前が取得できない場合、このメソッドは null
を返します。
// Log the names of all users who have edit access to a file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getName()); }
戻る
String
- ユーザーの名前。名前が使用できない場合は null
getPhotoUrl()
ユーザーの写真の URL を取得します。ユーザーの写真が利用できない場合は、このメソッドは null
を返します。
// Log the URLs for the photos of all users who have edit access to a file. const file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz'); const editors = file.getEditors(); for (let i = 0; i < editors.length; i++) { Logger.log(editors[i].getPhotoUrl()); }
戻る
String
- ユーザーの写真の URL。写真が利用できない場合は null
サポート終了のメソッド
getUserLoginId()
getUserLoginId()
非推奨。2013 年 6 月 24 日より、get
に置き換えられました。
ユーザーのメールアドレスを取得します。
// Log the email address of the person running the script. Logger.log(Session.getActiveUser().getUserLoginId());
戻る
String
- ユーザーのメールアドレス。