title: Dynamics CRM 2011: javascript, 'null' is null not an object. error
body: <p>I am using JavaScript on Dynamics CRM 2011. I am trying to create a new field  by comparing two date fields. however, I think something is wrong with null value. cas error message shows up: 'null' is null not an object.</p>
  
  <p>The following is the script. Please have a look, and let me know what you think. </p>
  
  <pre><code>function m1status() {
  
      var m1date = Xrm.Page.getAttribute("new_m1date").getValue()
  
      var today = Xrm.Page.getAttribute("new_todayis").getValue()
  
      if (m1date == null) {
  
          Xrm.Page.getAttribute("new_m1status").setValue('Not Booked');}
  
      else if (m1date.getTime() &gt;= today.getTime()) {
  
          Xrm.Page.getAttribute("new_m1status").setValue('Booked');}
  
      else {
  
          Xrm.Page.getAttribute("new_m1status").setValue('Completed');}
  
      //Set the Submit Mode
      Xrm.Page.getAttribute("new_m1status").setSubmitMode("always");
  
  }
  </code></pre>
  
  <p>Also most likely the default value is null. cas nothing is shown up.</p>
  
  <p>Thanks so much.</p>