title: Setting Script Property using it in "if" in Google
body: <p>I have a script that is supposed to mail a chart URL when a metric falls out of X range and Only if someone has entered a new metric.  It's mailing everytime I run the script so I know the setProperty is not working and the "if" statement isn't working because it's only supposed to mail if X is TRUE.</p>
  
  <p>The sheet...  <a href="https://docs.google.com/spreadsheet/ccc?key=0Ai_2YLvaQba0dHN1dWFpY0ZSbGpudWF4cTJYNlFwNHc&amp;usp=sharing" rel="nofollow">https://docs.google.com/spreadsheet/ccc?key=0Ai_2YLvaQba0dHN1dWFpY0ZSbGpudWF4cTJYNlFwNHc&amp;usp=sharing</a></p>
  
  <p>My code...</p>
  
  <pre><code>function myAverages() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var value = ss.getSheetByName("EmailServices").getRange("P2").getValue().toString();
    var outside = ss.getSheetByName("EmailServices").getRange("S2").getValue().toString;
    var mailed = ss.getSheetByName("EmailServices").getRange("T2").getValue().toString();
    var stemiAverage = ss.getSheetByName("EmailServices").getRange("R2").getValue().toString();
    var stemiChart = ss.getSheetByName("EmailServices").getRange("U2").getValue().toString();
    var last = ScriptProperties.getProperty('last');
  
    //if "value" is not equal to ScriptProperty "last" AND "outside" is TRUE, then mail   
    if(value =! last, outside = "TRUE")
  
    {
     MailApp.sendEmail("dave@mydomain.com", "Metric Warning",
      "Yearly STEMI Average has fallen below 65%, it is now: " + stemiAverage + "%" +
      "\n\nTo see the current trending chart " + stemiChart + "\n\n The sheet that    calculated this is here " + ss.getUrl());
     ScriptProperties.setProperty('last','value');
    }
  }
  </code></pre>
  
  <p>Thanks for any help you can lend.  I'm teaching myself this stuff and feel very much like a newby.  I've tried a hundred or more combinations to the script before posting here.</p>