title: How to re-execute the query script of an App Maker Datasource
body: <h2>Goal</h2>
  
  <p>Use App Maker to collect User Birthdays and display only the Birthdays this Month.</p>
  
  <h2>Issue</h2>
  
  <p>I have a data model, <code>persons</code>. In that model are two Datasources, the default <code>persons</code> and a second <code>birthdaysThisMonth</code>. The datasource query script in <code>birthdaysThisMonth</code> properly runs and returns only the birthdays this month from the <code>persons</code> model.</p>
  
  <p>However, when I change a birthdate in the <code>persons</code> datasource, the <code>birthdaysThisMonth</code> datasource remains unchanged, e.g., the Query script in <code>birthdaysThisMonth</code> is not <em>re-executed</em>.</p>
  
  <p>To change the birthdate, I select a new date from the date picker, and the new value is shown in a table. I am not using a submit button, I see the change when the date picker looses focus.</p>
  
  <h2>What I've Tried</h2>
  
  <p>This script is executed as a <em>Query script</em> in the <code>birthdaysThisMonth</code> datasource <em>which is <strong>not</strong> set to <code>Manual save mode</code></em>. It returns the records I want.</p>
  
  <pre><code>function setBirthdays() {
    var calcRecords = [];
    var personsRecords = app.models.persons.newQuery().run();
    for (i=0; i&lt;personsRecords.length; i++) {
      var id = app.models.persons.newQuery().filters.Id._equals = i;
      if (personsRecords[i].birthdate.getMonth() == thisMonth())  {
        var calcRecord = app.models.persons.newRecord();
        calcRecord.emailSecondary = personsRecords[i].emailSecondary;
        calcRecord.birthdate = personsRecords[I].birthdate;
        calcRecord.Id = personsRecords[i].Id;
        calcRecords.push(calcRecord);
      }
    }
    return calcRecords;
  }
  </code></pre>
  
  <h2>Question</h2>
  
  <p>How do I re-execute the query script in <code>birthdaysThisMonth</code> when the data in <code>persons</code> has been updated. How do I trigger the query so it reevaluates the data in <code>persons</code> and filters accordingly.</p>
  
  <p>Using Events and <code>onAfterSave</code> seems promising, but I haven't found an example of this.</p>
  
  <h2>BTW</h2>
  
  <p>I'd like this work to happen on the server side if possible. </p>