Class User

Użytkownik

Użytkownik powiązany z plikiem na Dysku Google. Użytkownicy mogą uzyskiwać dostęp do File.getEditors(), Folder.getViewers() i innych metod.

// 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());
}

Metody

MetodaZwracany typKrótki opis
getDomain()String|nullPobiera nazwę domeny powiązaną z kontem użytkownika.
getEmail()String|nullPobiera adres e-mail użytkownika.
getName()String|nullPobiera nazwę użytkownika.
getPhotoUrl()String|nullPobiera adres URL zdjęcia użytkownika.

Szczegółowa dokumentacja

getDomain()

Pobiera nazwę domeny powiązaną z kontem użytkownika.

// 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());
}

Powrót

String|null – nazwa domeny powiązana z kontem użytkownika.


getEmail()

Pobiera adres e-mail użytkownika. Adres e-mail użytkownika jest dostępny tylko wtedy, gdy użytkownik zdecyduje się udostępnić go na stronie ustawień konta Google+ lub gdy użytkownik należy do tej samej domeny co użytkownik uruchamiający skrypt, a administrator domeny zezwoli wszystkim użytkownikom w domenie na wyświetlanie adresów e-mail innych użytkowników.

// 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());
}

Powrót

String|null – adres e-mail użytkownika lub pusty ciąg znaków, jeśli adres e-mail jest niedostępny.


getName()

Pobiera nazwę użytkownika. Jeśli nazwa użytkownika jest niedostępna, ta metoda zwraca 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());
}

Powrót

String|null – imię i nazwisko użytkownika lub null, jeśli nie są dostępne.


getPhotoUrl()

Pobiera adres URL zdjęcia użytkownika. Jeśli zdjęcie użytkownika jest niedostępne, ta metoda zwraca wartość 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());
}

Powrót

String|null – adres URL zdjęcia użytkownika lub null, jeśli zdjęcie nie jest dostępne.

Wycofane metody