ผู้ใช้ที่เชื่อมโยงกับไฟล์ใน 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|null | รับชื่อโดเมนที่เชื่อมโยงกับบัญชีของผู้ใช้ |
get | String|null | รับอีเมลของผู้ใช้ |
get | String|null | รับชื่อของผู้ใช้ |
get | String|null | รับ URL ของรูปภาพของผู้ใช้ |
เอกสารโดยละเอียด
get Domain()
รับชื่อโดเมนที่เชื่อมโยงกับบัญชีของผู้ใช้
// 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|null — ชื่อโดเมนที่เชื่อมโยงกับบัญชีของผู้ใช้
get Email()
รับอีเมลของผู้ใช้ อีเมลของผู้ใช้จะใช้ได้ก็ต่อเมื่อผู้ใช้เลือกที่จะแชร์อีเมลจากหน้าการตั้งค่าบัญชี 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|null - อีเมลของผู้ใช้ หรือสตริงว่างหากไม่มีอีเมล
get Name()
รับชื่อของผู้ใช้ วิธีนี้จะแสดง 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 - ชื่อผู้ใช้ หรือ null หากไม่มีชื่อ
get Photo Url()
รับ 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|null — URL ของรูปภาพของผู้ใช้ หรือ null หากไม่มีรูปภาพ