Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during upsert on identical DeveloperName for RecordType of same sObject #3702

Merged
merged 10 commits into from
Dec 28, 2023

Conversation

aditya-balachander
Copy link
Contributor

W-11466074

Fixed a bug during upsert (load) of records where if the sObject had two record types with the same DeveloperName but different IsPersonType, duplicate records were being generated for load and as a result, error was thrown.

Example: For the sObject Account, the record type PersonAccounts has DeveloperName = PersonAccounts and IsPersonType = True. I could also create another recordType such that DeveloperName = PersonAccounts but the IsPersonType = False. In such cases, say I was trying to upsert 1 record (any update_key) with this PersonAccounts (one of the two), 2 records would try to get inserted and would throw a duplicate row error.

Copy link
Contributor

@lakshmi2506 lakshmi2506 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM , just add that testcase with same developername.

aditya-balachander and others added 6 commits November 14, 2023 11:51
Added test for upsert to check same DeveloperName but different IsPersonType on the RecordType
Fixed an error where if org has no person account enabled then IsPersonType column does not exist
jkasturi-sf
jkasturi-sf previously approved these changes Dec 26, 2023
Copy link
Contributor

@jkasturi-sf jkasturi-sf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix will resolve the duplicate record insertion issue when PersonAccount is enabled on the org and duplicate entries of PersonAccount are exists in RecordType entity.

@jkasturi-sf jkasturi-sf merged commit a9ff001 into main Dec 28, 2023
20 of 22 checks passed
@jkasturi-sf jkasturi-sf deleted the bug/record_type_uniqueness branch December 28, 2023 06:33
@aditya-balachander aditya-balachander restored the bug/record_type_uniqueness branch January 31, 2024 04:03
@aditya-balachander aditya-balachander requested review from jstvz and removed request for jstvz January 31, 2024 06:35
jstvz pushed a commit that referenced this pull request Feb 1, 2024
Fix for
[issue](https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007XIPZMSA5)
related to your recent PR
([3702](#3702)).

**Error Message:** `AttributeError: is_person_type`

**Issue Reason:**
During load, the tasks expects the column `is+person_type` to be present
in the record type table `rt_mapping_table`. This column is present for
sql files which do extract after the new release of CumulusCI (v3.84.0)
but will not be present for existing sql files.

**Fix:**
Previously the `outerjoins_to_add` function of the
`AddRecordTypesToQuery` class checks if the combination of
`is_person_type` and `developer_name` is unique. Now, if the
`rt_mapping_table` does not have the `is_person_type` table, the task
ignores the condition to check for record types based on
`is_person_type` and only checks for `developer_name` (as it was
previous to this PR
[3702](#3702))

---------

Co-authored-by: Jaipal Reddy Kasturi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants