Can't import to an EntityReference custom field
Overview
It's not possible to import to an EntityReference custom field, excepy by supplying the primary key of the entity.
It should be possible to import using the text that is used when selecting the record from an autocomplete - e.g. a Display Name for contacts, Title for events, etc.
Reproduction steps
- Create a custom field of type EntityReference.
- Try to import to that field (e.g. if your field displays organizations, import using an organization name).
Current behaviour
Error: custom_X is not a valid integer
(with X being the custom field's ID.
Expected behaviour
At a minimum, the field should be checked against existing values and converted to an integer. At best, it works similarly to importing relationships, where importing a missing value would create it.
In that case, it should also apply the filters of the EntityReference field - e.g. if it's specified that it filters to a certain contact subtype, that subtype should be applied.
Arguably it might be best to allow importing to entity references with a similar UI to that used for relationships, but this is way out of scope.
Comments
I'm working on a patch to support the "minimum" import I named. I've been having trouble though, so I may have to submit it as WIP and request some assistance in understanding.