Importing soft credit payments by email address fails with confusing message if dedupe rule requires extra fields
Overview
Importing soft credit payments (matched to existing contacts by email address) fails if the relevant Unsupervised dedupe rule requires any extra fields. The error message in this case is:
Invalid email address(doesn't exist) email@example.com. Row was skipped
The proposed change passes any required fields to the dedupe check if they are available in the import, but does not amend the error message if it fails.
Example use-case
- Add to the Unsupervised rule so it requires First and Last names as well as email address
- Import soft credit payments where the Fundraiser ID is set by External Identifier (or Contact ID) and the Donor is matched by email, First Name, and Last Name
Current behaviour
Currently each row in such an import will fail with this message:
Invalid email address(doesn't exist) email@example.com. Row was skipped
Proposed behaviour
If the required fields are available in the import data, they could be passed to the dedupe function. This is what I've done here (on version 5.39.2):
https://github.com/AsylumSeekersCentre/civicrm-core/commit/c924fb95a2e311a442656bf65c23523091d351da
If the required fields are not available, it would be better if the error message pointed the user in the right direction. Currently it says that the email address does not exist, but in the case of our import, all of the email addresses did exist for contacts of the appropriate type. I haven't addressed this part of the issue with the code above.
Comments
I think the patch above is not the whole solution. That code pathway is used when there is no External Identifier or Contact ID but there is an email address. It then calls the Unsupervised dedupe rule, which may not refer to the email address at all (though the default does). The change I've proposed accommodates extra fields added to the rule, but doesn't consider the possible removal of the email address from the rule.