Enum ProtectionType

Protection Type

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. 
 const 
  
 ss 
  
 = 
  
 SpreadsheetApp 
 . 
 getActive 
 (); 
 const 
  
 protections 
  
 = 
  
 ss 
 . 
 getProtections 
 ( 
 SpreadsheetApp 
 . 
 ProtectionType 
 . 
 RANGE 
 ); 
 for 
  
 ( 
 const 
  
 protection 
  
 of 
  
 protections 
 ) 
  
 { 
  
 if 
  
 ( 
 protection 
 . 
 canEdit 
 ()) 
  
 { 
  
 protection 
 . 
 remove 
 (); 
  
 } 
 } 
 // Removes sheet protection from the active sheet, if the user has permission to 
 // edit it. 
 const 
  
 sheet 
  
 = 
  
 SpreadsheetApp 
 . 
 getActiveSheet 
 (); 
 const 
  
 protection 
  
 = 
  
 sheet 
 . 
 getProtections 
 ( 
 SpreadsheetApp 
 . 
 ProtectionType 
 . 
 SHEET 
 )[ 
 0 
 ]; 
 if 
  
 ( 
 protection 
 ? 
 . 
 canEdit 
 ()) 
  
 { 
  
 protection 
 . 
 remove 
 (); 
 } 

Properties

Property Type Description
RANGE
Enum Protection for a range.
SHEET
Enum Protection for a sheet.
Create a Mobile Website
View Site in Mobile | Classic
Share by: