Stay organized with collections
Save and categorize content based on your preferences.
ProtectionType
An enumeration representing the parts of a spreadsheet that can be protected from edits.
To call an enum, you call its parent class, name, and property. For example,
SpreadsheetApp.ProtectionType.RANGE.
// Remove all range protections in the spreadsheet that the user has permission// to edit.constss=SpreadsheetApp.getActive();constprotections=ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);for(constprotectionofprotections){if(protection.canEdit()){protection.remove();}}
// Removes sheet protection from the active sheet, if the user has permission to// edit it.constsheet=SpreadsheetApp.getActiveSheet();constprotection=sheet.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];if(protection?.canEdit()){protection.remove();}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["`ProtectionType` is an enum used to specify whether you are working with sheet or range protection in Google Apps Script."],["It has two properties: `SHEET` and `RANGE`, that are used with the `getProtections()` method to retrieve the corresponding protections."],["You can use `ProtectionType` to remove or modify existing protections within your spreadsheet, given the necessary permissions."]]],[]]