title: Received a Unable to get value of the property 'Execute': object is null or undefined with Jscript - Crm2011 Onchange Event
body: <p>I created 3 whole number fields in a CRM form:  var1  var2  and result</p>
  
  <p>I need  var 2 to be subtracted from var1  and display the result, in the result field</p>
  
  <p>Added the Jscript code to the form event,  and added an onchange event to the var1 and var2 field.</p>
  
  <p>I'm receiving the error:<br>
  Unable to get value of the property 'Execute': object is null or undefined  </p>
  
  <p>Here's my JScript: </p>
  
  <pre><code>function calculates( )
  {
  
      var val1 = Xrm.Page.entity.attributes.get(safe_val1).getValue();
      var val2 = Xrm.Page.entity.attributes.get(safe_val2).getValue();
  
      if(val1=null) return;
      if(val2=null) return;
  
      var result = val1 - val2;
  
      Xrm.Page.entity.attributes.get(safe_result).setValue(result);
  }
  </code></pre>
  
  <p>Thanks in advance to anyone who answers my question!</p>