title: dynamics crm 4.0 lookup field onload() query
body: <p>I have an account entity with a lookup field <code>schoolLookupId</code> which refers back to a custom entity <code>new_schools</code>. The lookup field only display the name of the school. What I would like to be able to do using the <code>onload()</code> event handler of the account form is to run some javascript code that will query the <code>new_phonenumber</code> attribute of the <code>new_schools</code> entity to see if it matches a value i provide lets say <code>var x = "1234"</code> and if it does then update <code>schoolLookupId</code> accordingly with the name of the school that corresponds with the found phone number. i.e update the lookup field with a phone number that already exists <strong>without</strong> creating a completely new lookup value. </p>
  
  <p>I can get the attributes of the lookupfield using</p>
  
  <pre><code>var name = crmForm.all.schoolLookupid.DataValue[0].name
  var id = crmForm.all.schoolLookupid.DataValue[0].id
  var typename = crmForm.all.schoolLookupid.DataValue[0].typename
  </code></pre>
  
  <p>but I can't figure out how to retrieve, compare the data that lies behind the lookup field, and update the lookupfield accordingly.</p>
  
  <p>Your help as always is invaluable.</p>