title: onEdit can programmatically create a trigger?
body: <p>I wrote a simple script trying to programmatically create a script from the onEdit function</p>
  
  <pre><code>function onEdit() {
    test();
  }
  
  function test() {
    triggerLater();
  }
  
  function customMsgBox() {
    Browser.msgBox("hello world");
  }
  
  function triggerLater() {
    var date = new Date();
    date.setMinutes(date.getMinutes() + 1);
    try {
      var oneTimeOnly = ScriptApp.newTrigger("customMsgBox")
        .timeBased()
        .at(date)
        .create();
      return oneTimeOnly.getUniqueId();
    }
    catch (e) {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      ss.toast("error");
    }
  }
  </code></pre>
  
  <p>If I try to run onEdit from the script editor the trigger is created but every edit on the spreadsheet get a "error" message in a <em>toast</em></p>
  
  <p>Can someone help me to understand ?</p>