Re-use existing email, phone, and address fields in CRM's custom fields

Created on 1 May 2025, 14 days ago

Problem/Motivation

CRM has developed / is developing completely custom field types for tracking a contact's email addresses, phone numbers, and addresses. Unfortunately this means that the extensive contributed ecosystem that extends and benefits from existing core/contrib modules providing email, phone, and address field types would require bespoke integration with CRM. For example, as it stands, creating a view that results in a map with contacts' addresses plotted on it would require a lot of work.

Proposed resolution

CRM decorate existing field types to provide the enhancements provided by CRM's custom field types while ensuring that existing contrib projects can enhance / benefit from the underlying data.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jdleonard Austin, TX, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jdleonard
  • πŸ‡ΊπŸ‡ΈUnited States jdleonard Austin, TX, USA

    I'm asking the Member Platform team to dive into this during today's Slack meeting.

  • πŸ‡ΊπŸ‡ΈUnited States jdleonard Austin, TX, USA

    Taking phone as a simple(r) example, I went down a bit of a rabbit hole.

    It's late so I'm going to need to come back to this later, but some quick-ish thoughts...

    There are quite a few contrib projects that define their own phone field type. There are some contrib projects that provide validation and/or a formatter for the core telephone field type. I think we should leverage some of the existing functionality provided elsewhere in contrib by A) extending one or more field types, field formatters, and/or field widgets or otherwise ensuring we don't lose out and we don't reinvent the wheel; and/or B) using a field collection or entity (see below) to allow wholesale use of an existing project's field type. Further analysis needed.

    https://www.drupal.org/project/telephone_advanced β†’
    https://www.drupal.org/project/telephone_validation β†’
    https://www.drupal.org/project/telephone_formatter β†’
    https://www.drupal.org/project/telephone_plus β†’
    https://www.drupal.org/project/telephone_type β†’
    https://www.drupal.org/project/telephone_international_widget β†’
    https://www.drupal.org/project/phone_international β†’
    https://www.drupal.org/project/phonenumber β†’

    I'm increasingly wary of CRM using a field type that is essentially a bunch of fields related to a phone number, but that are quite a bit more than a phone number. More complex use cases could need to track data (that we aren't currently anticipating) about each phone number such that it would be beneficial for a phone number to be fieldable. We can't change the field schema later ✨ Field type modules cannot maintain their field schema (field type schema change C(R)UD is needed) Needs work . While there are obvious downsides, I think we should discuss using a field collection or defining an entity to capture the various data related to a phone number.

    Additional things that might warrant tracking per phone number, whether as a field or a reference from some other entity to a Contact's phone number:

    • Confirmation status (similar to confirming an email address)
    • Opt-in/out
    • Communication preferences
    • Activity (e.g. calls or texts to/from)

    I'm not suggesting that any of these should be tracked for 1.0 (or even necessarily in a future CRM release). Similarly, I think we should not track mobile carrier in 1.0.

    I haven't gone down the rabbit hole for the other field types, but I plan to. I suspect I will come to similar conclusions.

  • πŸ‡ΊπŸ‡ΈUnited States mradcliffe USA

    Would it be helpful to split this issue to tackle each of email, address and telephone separately? That way we can reduce the size of the merge request for reviewers and testers. It could mean an eventual merge conflict for update hooks.

  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    So it seems like there are several different aspects to this question, from a CRM perspective:

    ## What is the contact info?

    Different aspects here:

    - Validating the phone number - does it fit validation rules for the country? Does it allow for PBX things like extensions, or voice rules to reach a person?
    - Identifying the phone number -- home, work, mobile, etc
    - Can it accept an SMS? Fax?
    - How do we know which number the contact wants to use?
    - Is there a place to add a note to help answer these questions?

    ## What contact method does the person prefer?

    There have been several attempts to provide preferred contact methods a user can select. There used to be Message Framework, Notifications, Courier. For D11, I see DANSE β†’ and I see a dev " Notifier β†’ " module leveraging a Symfony system.

    Looks like at the moment DANSE is the clear active project in use that provides a framework for this aspect.

  • πŸ‡ΊπŸ‡ΈUnited States jdleonard Austin, TX, USA

    @mradcliffe, Yes I think it could make sense to split this issue, but perhaps it would be wise for us to first determine the overall desired approach as there are some analogous needs across the different fields.

    @freelock Good considerations. I'm arriving at the conclusion that it might not be realistic for us to determine all the likely needs up front so it would be wise to make phone number related data extensible (i.e. a field collection or entity type rather than a custom field whose columns are immutable).

    A quick look at DANSE suggests to me that it isn't set up to handle non-User entities as first-class recipients. However, Notifier β†’ has documentation making clear that it does. I posted a message in the #danse Slack channel to confirm and will report back.

  • πŸ‡ΊπŸ‡ΈUnited States jdleonard Austin, TX, USA

    As requested by @bluegeek9 in today's Member Platform meeting πŸ“Œ Member Platform (Zoom) Meeting on May 8, 2025 Active , I'm going to prototype a CRM Contact Address entity type (or Storage β†’ Type) with an Address β†’ field, its integration with CRM Contact via Inline Entity Form, and plotting contacts' addresses on a map to illustrate the value of using the contrib address field.

  • πŸ‡ΊπŸ‡ΈUnited States freelock Seattle

    Should also consider if/how SimpleNews might fit into this...

  • πŸ‡ΊπŸ‡ΈUnited States jdleonard Austin, TX, USA

    Yes, good idea.

    jurgenhaas, DANSE maintainer and Member Platform supporter, replied:

    that's correct, DANSE currently is built to users as recipients. Thinking about it, extending that to entities as recipient in general, shouldn't be hard. So, if DANSE otherwise is appealing, I'd be willing to make that enhancement.

    We should probably move this discussion into a different issue.

  • Pipeline finished with Success
    6 days ago
    Total: 435s
    #492952
  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    bluegeek9 β†’ changed the visibility of the branch 3522243-reuse-fields to hidden.

  • Pipeline finished with Success
    about 15 hours ago
    Total: 374s
    #497570
  • πŸ‡ΊπŸ‡ΈUnited States jdleonard Austin, TX, USA

    Please see comments in the MR

  • Pipeline finished with Success
    about 11 hours ago
    Total: 250s
    #497669
  • Pipeline finished with Success
    about 11 hours ago
    #497676
Production build 0.71.5 2024