Multivalue contact reference field
The current contact reference field only allows a single contact reference.
A contact reference field that allows multiple contacts would be really useful for some use cases, e.g. https://civicrm.stackexchange.com/questions/30405/custom-field-multiple-contact-references
What would it take to add an option to the Contact Reference field type to allow it to contain multiple contact references?
Similar 'Multi-select' functionality is exposed for the following field types:
- Alphanumeric > Select
- Integer > Select
- Alphanumeric > Checkbox is inherently multi-select.
IIRC, in each of these cases, references to multiple contacts are stored in the database in a single field with the null character used to separate the various multiple options. Certainly that is the case for the Country field when I looked just now.
Although this approach means that we can't do any referential integrity checking for these fields, it does make the database architecture more straight forward (less joins, etc.). And the plumbing already exists to allow queries along the lines of 'Show me all contacts where this value is one of the multi-values' in advanced search and (I think I am right in saying) api3 and 4.
My instinct is that it would be a good idea to follow this precedent for multi-value contact reference fields.
- The approach used for Activity target contacts. Although this is more conventional approach it seems so outside of the approach that we can taken to custom data so far that I am not sure that we could actually implement it
- Use multiple record custom data sets. These can only be added to contacts, and one has to define this at the custom data set level which would restrict its usefulness.
At this stage I am looking for thoughts on feasibility, gotchas, links to any related / relevant / previous / discussion, wondering if it has been tried before, etc.
Thanks for your input :)