prairieskygal
prairieskygal

Reputation: 3

Google script: getUser() not working

If anyone can offer advice about why this function isn't working, I would appreciate it. It's basically copied right out of the Google API reference: https://developers.google.com/apps-script/class_pageprotection#getUsers

function getUsers() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var permissions = sheet.getSheetProtection();
  var users = permissions.getUsers();

  Browser.msgBox(users);
}

When I run the script, I get an empty box with the title "Apps Script" and no list of users.

Any help would be greatly appreciated. Thanks!

Jessica

Upvotes: 0

Views: 437

Answers (1)

Claudio Cherubino
Claudio Cherubino

Reputation: 15004

That function only returns values when sheet protection is enabled (by selecting Tools - Protect Sheet).

When the sheet is protected, the function will return the list of users you granted access to and the code will work as expected.

Upvotes: 1

Related Questions