function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MegachuckmcMegachuckmc 

Apex Trigger to Update a Lookup field

I'll start with the oft-used disclaimer... I'm not an Apex developer... have never written any Apex code etc... But I'm trying to do something that would appear to be simple but everywhere I look it says that what I want to do can only be done with an Apex Trigger... So... I have a custome Object called SalesOrderHeaders which captures information from our ERP system using the Apex Data Loader. One of those fields is the 'Account Name' which was of course is set up as a Lookup field with a relationship to Accounts. The value for 'Account Name' that comes out of the ERP system is simply a name (i.e. Yahoo Inc.) but when I attempt to Upsert this into my SaleOrderHeaders object in SFdc, it wants the Accound ID value rather than the actual text value of the field.
sgkmillssgkmills

I do updates like this all the time and the best way is to have the ids stored in the ERP system, then you have a 1-1 match with the data in Salesfore and updates are very easy.  It is kind of deceptive because the lookup field shows the account name, but when you try to do an insert/update it wants the account id.

 

Hope this helps.