title: Apex Trigger to Update Lookup Field (Contact)
body: <p>Need some advise on how to populate a lookup field (contact) via apex trigger</p>
  
  <ol>
  <li>I've created a lookup field called Contact__c on Idea object.</li>
  <li>I would like to populate the Contact__c with the createdby User if it was originated from the web (CreatedBy.Contact.Account.Name == "Web Ideas") and leave it empty for internal idea creation.</li>
  <li>I have read up and created the following trigger and was able to save and run. However, upon saving the idea record, i am getting an error : UpdateContactonComplaints: data changed by trigger for field Contact: id value of incorrect type: 005N0000000l9iMIAQ</li>
  </ol>
  
  <p>trigger UpdateContactonComplaints on Idea (before insert, before Update) {    </p>
  
  <pre><code>list&lt;id&gt; oid = new list&lt;id&gt;();
  for(Idea o: trigger.new){                   
      oid.add(o.id);
          }
  map&lt;id, Idea&gt; ExtendU = new map&lt;id, Idea&gt;(
      [select CreatedbyID from Idea where id in: oid]);
  
  for(Idea o: trigger.new){
      o.Contact__c = ExtendU.get(o.id).CreatedbyID;
  }
  </code></pre>
  
  <p>}</p>