Within the CRM database, where can I find the name of the entity that a lookup field relates to?
For example, I have an Account
entity which contains two lookup fields;
- Account Contact, which points to the
Contact
entity - Leased Equipment, which points to the
Equipment
entity
How can I get the name of the entity that each of the fields relates to?
I expected to see this in the MetadataSchema.AttributeLookupValue
table, but this doesn't seem to be the right place.
Ideally, I'd like to write a query for this information. Something along the lines of:
SELECT
AttributeName,
AttributeTypeName,
ReferencedEntityName
FROM
unknown.TableName
WHERE
AttributeName IN ('new_AccountContact', 'new_LeasedEquipment')
-- Results:
-- AttributeName | AttributeTypeName | ReferencedEntityName
-- new_AccountContact | lookup | Contact
-- new_LeasedEquipment | lookup | Equipment
Any help trying to achieve this would be appreciated, thanks.