0
votes

I have a list of field names from an entity that I know are all lookup fields. I need to know which entity they are lookups to so that I can do further processing of the data.

Is there a way in a plugin that I can find this out just from having the field name?

2

2 Answers

1
votes

In a plugin, a lookup field is represented by the EntityReference type.

var lookup = entity.GetAttributeValue<EntityReference>("new_fieldname");
var entityName = lookup.LogicalName;
var entityId = lookup.Id;
var instanceName = lookup.Name;
0
votes

I think this is what you are looking for:

string lookupEntityName = entity.new_lookupFieldName.LogicalName;

LogicalName will give you the name of the Entity.