Resolve Issue #3927: contact import failure of different related contact typess #24801
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR resolves issue 3927, which flags that the Contact Import was failing when the related contact was of a different contact type as the main contact being imported.
Issue replication steps:
Before
When importing contacts when the main contact was an Individual and the contact related contact was an Organization (i.e. to create an "Employee of" relationship on import), the import failed with a reason of "Mismatched contact types." This scenario was caused by the dedupe rule for the main contact being applied to the contact related contact as well.
After
With this patch, the Contact Import no longer applies the same dedupe rule to the contact related contact if it is of a different contact type than the main contact. As a result, the import does not fail when establishing a relationship between two different contact types on import.
Technical Details
The original code was not comparing the contact types to determine which dedupe rule should be applied, so this patch initiates a comparison of the contact types via
$this->getSubmittedValue('contactType')
and$params['contact_type']
and then makes an APIv4 call toDedupeRuleGroup
to get the id ofunsupervised
rule that corresponds with the correct contact type.This PR also includes modifications to
testImportParserWithEmployeeOfRelationship
. This test was passing both with and without the above changes, as it was not actually testing the dedupe portion of the import. Previously, this test did not set an email as part ofcontactImportValues
for deduping the main contact or pass a'dedupe_rule_id'
to$this->getUserJobID
so the dedupe rule was using the default value ofNULL
. By modifying these aspects of the test and using an APIv4 call to get the$ruleGroupId
, this code more accurately tests importing-and deduping- contacts of two different types.