Class User

User

Un utente associato a un file su Google Drive. È possibile accedere agli utenti da File.getEditors(), Folder.getViewers() e altri metodi.

// Log the email address of all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getEmail());
}

Metodi

MetodoTipo restituitoBreve descrizione
getDomain()StringRestituisce il nome di dominio associato all'account dell'utente.
getEmail()StringConsente di acquisire l'indirizzo email dell'utente.
getName()StringRestituisce il nome dell'utente.
getPhotoUrl()StringConsente di acquisire l'URL della foto dell'utente.

Documentazione dettagliata

getDomain()

Restituisce il nome di dominio associato all'account dell'utente.

// Log the domain names associated with all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getDomain());
}

Ritorni

String: nome di dominio associato all'account dell'utente


getEmail()

Consente di acquisire l'indirizzo email dell'utente. L'indirizzo email dell'utente è disponibile solo se l'utente ha scelto di condividere l'indirizzo dalla pagina delle impostazioni dell'account Google+ o se appartiene allo stesso dominio dell'utente che esegue lo script e l'amministratore di dominio ha consentito a tutti gli utenti del dominio di vedere gli indirizzi email di altri utenti.

// Log the email address of all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getEmail());
}

Ritorni

String: l'indirizzo email dell'utente o una stringa vuota se l'indirizzo email non è disponibile


getName()

Restituisce il nome dell'utente. Questo metodo restituisce null se il nome dell'utente non è disponibile.

// Log the names of all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getName());
}

Ritorni

String: nome dell'utente o null se il nome non è disponibile


getPhotoUrl()

Consente di acquisire l'URL della foto dell'utente. Questo metodo restituisce null se la foto dell'utente non è disponibile.

// Log the URLs for the photos of all users who have edit access to a file.
var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
var editors = file.getEditors();
for (var i = 0; i < editors.length; i++) {
  Logger.log(editors[i].getPhotoUrl());
}

Ritorni

String: URL della foto dell'utente o null se la foto non è disponibile

Metodi deprecati