title: Protect Row using username data on Google sheet
body: <p>I am able to read a manipulate scripts but am unable to write my own effectively.  I would like to ask for some help.  </p>
  
  <p><strong>The Issue:</strong> I have a sheet where managers most go in and make their approval or rejection right from the sheet.  Their email addresses are in the sheet as data. </p>
  
  <p><strong>Goal:</strong> I have been trying to find a script I can modify that will look at the column the user's emails at kept and use that data to set the permission for the row automatically instead of me having to create the protected ranges manually for 700+ managers. </p>
  
  <p>I really appreciate any help on this.</p>
  
  <p>The following is what little code I've been experimenting with. I don't know if it will help.  </p>
  
  <pre><code>enter code herefunction initiate (){
  
  var values = SpreadsheetApp.getActiveSheet().getDataRange().getValues()
  for(n=0;n&lt;values.length;++n){
  var user = values[1][1] ; // x is the index of the column starting from 0
  var manager = user.valueOf();
  
  Logger.log(manager);
  }
  
  var protections = values.getProtections(SpreadsheetApp.ProtectionType.RANGE);
  for (var i = 0; i &lt; protections.length; i++) {
  var protection = protections[i];
  if (protection.canEdit()) {
   protection.remove();
   }
  </code></pre>
  
  <p>}
     }</p>