In Dynamics 365 CRM you can add a field to an entity that has the data type “Customer”. In that field, the user can choose if he or she wants to select an Account or a Contact.

But how can you achieve something like that? Create a field that can hold an EntityReference to one of two or more different entity types?

It would have been so neat if you could, but unfortunately, there is no way to do that, so the answer will have to be: “I’m sorry Dave! I’m afraid you can’t do that”.

Best Workaround proposal:

The best solution I can think of is to create a string type field for the entity/class name and another string type field to hold the id in Guid format.

You won’t be able to click and jump to the selected entity as you can with a “normal” Lookup data type control (or the above mentioned Customer data type control), but you can use the fields to create an EntityReference in your C# code, either in a plugin or in an external program. Code sample:

EntityReference ref = new EntityReference(record.Attributes["entity logical name field"], new Guid(record.Attributes["entity guid string field"]));

Don’t forget null checking and format validation!