Get and set value from lookup field CRM plugin C#

Get Value of Lookup fields
EntityReference entref = (EntityReference)item.Attributes[attributeName];

var LookupId = entref.Id;

var logicalName = entref.LogicalName;

Set Value of Lookup fields
newAccount[attributeName] = new EntityReference(logicalName, LookupId);

Set Null Value of Lookup fields
newAccount[attributeName] = Null;

Leave Comment

Your email address will not be published. Required fields are marked *