Hi,
Use below code to retrieve lookup field value from CRM Plugin -
// Code to retrieve record from CRM based on Record GUID
Entity targetEntity= _service.Retrieve("Entityname", RECORDGUID,new ColumnSet("Lookup field Logical name"));
// You can also get TrahetEntity from plugin context using below code
Entity targetEntityFromContext=(Entity)context.InputParameters["Target"];
if(targetEntity.Attributes.Contains("Lookup field Logical name"))
{
EntityReference lookupfieldvalue=(EntityReference)targetEntity.Attributes["Lookup field Logical name"];
Guid lookupfieldGuid=lookupfieldvalue.Id;
string lookupfieldEntityName=lookupfield.LogicalName;
}
Good Luck!
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/