在谷歌片,我試圖用一個腳本,使受保護的範圍。無法使用腳本的保護範圍編輯權限刪除有效用戶 - Google表格
我想腳本,使只有擁有者可以編輯受保護的範圍,並沒有其他人,但腳本有當它運行的是誰不是所有者用戶的工作。
當我登錄的電子表格的所有者,並且我從運行腳本編輯器的代碼,它工作正常 - 它創建了一個保護的範圍G1:G10只有擁有者可以編輯。
然而,當我運行該腳本登錄的同時誰是不是所有者,受保護範圍的權限允許的用戶和編輯的範圍主人能力的用戶。我所知道的this page和this page,對谷歌的開發者文檔,但我看不到任何東西,會幫我。
這裏是我的代碼:
function setProtections() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var owner = ss.getOwner();
var effectiveUser = Session.getEffectiveUser();
var range = ss.getRange('G1:G10');
var protection = range.protect()
var editors = protection.getEditors();
protection.removeEditors(editors);
protection.addEditor(owner);
}
誰能幫助?