Exception: Unable to set domain edit permissions on worksheets outside a domain.

97 views
Skip to first unread message

Petrius Fabricio Ferreira

unread,
Jun 23, 2023, 9:29:17 AM6/23/23
to Google Apps Script Community
The script does not work, the message appears: "Exception: Unable to set domain edit permissions on worksheets outside a domain." How can I fix?

function bloquearIntervalos() {
  var planilha = SpreadsheetApp.getActiveSpreadsheet();
  var abas = planilha.getSheets();

  var intervalos = [
    'A1:BI1', // Cabeçalho
    'A2:A20', // Controle
    'G2:G20', // Cod Fam
    'H2:H20', // Caso está ativo?
    'K2:K20', // Idade
    'K3:S20', // Endereço
    'R2:R20', // Regional
    'AB2:AB20', // Idoso
    'AL2:AM20', // Cálculo de Renda
    'AU3:AZ20', // Características dos Caso
    'BB2:BF20' // PIFA
  ];

  for (var i = 1; i <= 52; i++) {
    var abaNome = ("0" + i).slice(-2);
    var aba = planilha.getSheetByName(abaNome);

    // Bloquear intervalos
    for (var j = 0; j < intervalos.length; j++) {
      var intervalo = aba.getRange(intervalos[j]);
      var protecao = intervalo.protect();
      protecao.addEditor(Session.getActiveUser());
      protecao.removeEditors(protecao.getEditors());
      protecao.setDomainEdit(false);
    }
  }
}

cbmserv...@gmail.com

unread,
Jun 23, 2023, 3:54:40 PM6/23/23
to google-apps-sc...@googlegroups.com

This is saying that the spreadsheet is not owned by a domain. If you are not using a Workspace account with domains, then you should not bother with that command and just remove that line in the script.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/a34f78f7-f051-4d3b-97e0-df7f498c158dn%40googlegroups.com.

Petrius Fabricio Ferreira

unread,
Jun 24, 2023, 2:45:17 PM6/24/23
to google-apps-sc...@googlegroups.com
Thank you very much, it solved my problem, I was almost giving up on this script.
(31)982132032

"Aquila non capit muscas." - Giovanni Battista Casti


Reply all
Reply to author
Forward
0 new messages