title: Dynamics 365 Javascript to access form field values
body: <p>How can I access form field values using Javascript in Dynamics 365 online?  This is what I've tried:</p>
  
  <p>A script web resource with an "onload" event called on the form "load".  This doesn't work.  I get <code>[Object object]</code> but I expect a string.  Debugging it shows no properties with the value of the field</p>
  
  <pre><code>function loadForm()
  {
      var value1 =    Xrm.Page.data.entity.attributes.get("new_dealercode").getValue();
      alert(value1);
  }
  </code></pre>
  
  <p>An HTML web resource that I include on the form, this does nothing, but I know it's being called because if I put an alert on it, it is alerted.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
      var value1 = window.parent.Xrm.Page.getAttribute("new_dealercoder").getValue();
      alert(value1);
  &lt;/script&gt;&lt;meta charset="utf-8"&gt;
  &lt;/head&gt;&lt;body&gt;&lt;br&gt;&lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What I'm trying to achieve:
  An Iframe with dynamic "src" based on a field value on the form.</p>