Specify relationships list for sub type contacts doesn't populate properly

Created on 7 November 2022, about 2 years ago
Updated 1 February 2023, almost 2 years ago

1.0 Problem/Motivation
Adding a default value of type 'relationship to' for contacts that have a subtype does not populate the list of relationships properly both ways.
When retrieving the relationship entries it will only match when the subtype order is the a to b way around.
Otherwise due to the reciprocal variable it doesn't check the subtype relationship b to a and the relationship is not available for the user to select.

2.0 Detailed steps to reproduce (embed screenshots)
Create a new relationship type (e.g Test Relationship)
Set contact a type 'Team' & contact b type 'Sponsor'

Create a civicrm webform with 3 contacts of type organisation & add the autocomplete field.
Set contact 1 & 3 to subtype 'Team'
Set contact 2 to subtype 'Sponsor'

Edit the Contact 3 autocomplete field, Set the 'Default value' as 'Relationship To Contact 2'
'Specify Relationship' properly populates 'Test Relationship' as an entry.

Edit the Contact 2 autocomplete field, Set the 'Default value' as 'Relationship to Contact 1'
'Specify Relationship' incorrectly does not list any relationships.

3.0 Proposed resolution
Tweak the conditional that builds the list to check for a relationship both ways by removing $reciprocal.
To avoid it printing twice add the reciprocal check when adding the label as it does for the first time.
This allows for situations where the subtype check fails a to b but is then added in b to a.

Edit the Contact 3 autocomplete field, Set the 'Default value' as 'Relationship To Contact 2'
'Specify Relationship' properly populates 'Test Relationship' as an entry.

Edit the Contact 2 autocomplete field, Set the 'Default value' as 'Relationship To Contact 1'
'Specify Relationship' properly populates 'Test Relationship' as an entry.

🐛 Bug report
Status

Fixed

Version

6.2

Component

Webform/Drupal

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024