SharePoint - Updating External Lookup Field
Update a Business Connectivity Services external lookup field on a list item using SPBusinessDataField and EntityInstanceIdEncoder.
Updating an external lookup (business data) field is a bit different from updating other lookup fields. This snippet shows how.
csharp
SPBusinessDataField dataField = item.Fields["Field Display Name"] as SPBusinessDataField;
item[dataField.RelatedField] = EntityInstanceIdEncoder.EncodeEntityInstanceId(new object[] { NEWVALUE });
item["Field_x0020_Internal_x0020_Name"] = newCRMNumber;
itemis the list item you are modifying.item.Fields["Field Display Name"]needs the display name of the external field.dataField.RelatedFieldis the hidden field that stores the encoded entity identifier.- The last line sets the visible column, using its internal name.
Call item.Update() afterwards to save the change.