title: How to remove actions taken by onEdit trigger from the undo history list in Google Sheets and App Scripts
body: <p>In one of my sheets, I'm using a simple script to change the borders of some cells on every edit. </p>
  
  <p>It kinda looks like this:</p>
  
  <pre><code>function onEdit(e) {
      ...
      sheet.getRange(1, 1, sheet.getMaxRows(), sheet.getMaxColumns()).setBorder(null, null, null, null, false, false);
      sheet.getRangeList(rangeList).setBorder(null, null, true, null, false, false, "#BBDEFB", SpreadsheetApp.BorderStyle.SOLID_THICK);
    }
  }
  </code></pre>
  
  <p>Everything works nicely, however, after editing something, lets say I press CMD+Z (or CTRL+Z) to undo my last action. What actually happens is that the border that was added gets removed, because technically that was the last action. </p>
  
  <p>Is there a well known solution to problems of this nature?</p>
  
  <p>Edit:
  I created a manual trigger function based on the first answer. However, Google Sheets has a limit of one trigger per user per spreadsheet. So the borders were changed only once. I also deleted the trigger as it said so, and even then it did not work.</p>
  
  <p><strong>Moreover, is there a better way to do this? Setting the borders to null on every edit basically makes it impossible to add custom borders at all.</strong> </p>