title: Using ScriptDB Query in onEdit() function in Google Spreadsheet Apps Script
body: <p>So</p>
  
  <p>I'm getting this error </p>
  
  <blockquote>
    <p>Oops You do not have permission to call query (line 7)</p>
  </blockquote>
  
  <p>When I try to query a ScriptDB database in an onEdit() function within Google Spreadsheet Apps script. Below is the code I use to get the repeatable error:</p>
  
  <pre><code>function onEdit(){
    //tell me event has happened
    Browser.msgBox("onEdit() Fired")
    //get ScriptDB reference
    var db = ScriptDb.getMyDb();
    //perform any query
    var results = db.query({})
  }
  </code></pre>
  
  <p>Replace onEdit() with notonEdit() and it works as expected when triggered manually.</p>
  
  <pre><code>function notonEdit(){
    //tell me event has happened
    Browser.msgBox("notonEdit() Fired")
    //get ScriptDB reference
    var db = ScriptDb.getMyDb();
    //perform any query
    var results = db.query({})
  }
  </code></pre>
  
  <p>Is there some sort of permission I am not correctly setting or are ScriptDB queries not allowed to function in event functions by design? Is anybody else seeing this problem?</p>
  
  <p>Tom</p>