Stay organized with collections Save and categorize content based on your preferences.
UserA user associated with a file in Google Drive. Users can be accessed from File.getEditors()
, Folder.getViewers()
, and other methods.
// 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()); }Methods Method Return type Brief description
getDomain()
String
Gets the domain name associated with the user's account. getEmail()
String
Gets the user's email address. getName()
String
Gets the user's name. getPhotoUrl()
String
Gets the URL for the user's photo. Deprecated methods Method Return type Brief description getUserLoginId()
String
Gets the user's email address. Detailed documentation getDomain()
Gets the domain name associated with the user's account.
// 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()); }Return
String
— the domain name associated with the user's account
getEmail()
Gets the user's email address. The user's email address is only available if the user has chosen to share the address from the Google+ account settings page, or if the user belongs to the same domain as the user running the script and the domain administrator has allowed all users within the domain to see other users' email addresses.
// 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()); }Return
String
— the user's email's address, or a blank string if the email address is not available
getName()
Gets the user's name. This method returns null
if the user's name is not available.
// 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()); }Return
String
— the user's name, or null
if the name is not available
getPhotoUrl()
Gets the URL for the user's photo. This method returns null
if the user's photo is not available.
// 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()); }Return
String
— the URL for the user's photo, or null
if the photo is not available
getUserLoginId()
Deprecated. As of June 24, 2013, replaced by getEmail()
.
Gets the user's email address.
// Log the email address of the person running the script. Logger.log(Session.getActiveUser().getUserLoginId());Return
String
— The user's email's address.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["A User in Google Drive represents an individual associated with a file or folder, accessible through methods like `getEditors()` and `getViewers()`."],["You can retrieve user information such as their domain, email address, name, and photo URL using dedicated methods of the `User` object."],["The `getUserLoginId()` method is deprecated and has been replaced by `getEmail()` for accessing a user's email address."],["User email addresses might not be available if privacy settings restrict access or if domain-wide sharing isn't enabled."],["User names and photo URLs may return `null` if they are not available or have not been set by the user."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4