Description | Salesforce only allows one Account Contact Relationship (AccountContactRelation) record to be created between each Business Account (Account) and Person Account (Contact) record. If duplicate Account Contact Relationship records are created for the same Business Account and Person Account records, Salesforce will throw an error. However, there are two scenarios in which Care Connect may currently try to create duplicate Account Contact Relationship records via Case Field Configuration (mvn__PJN_Case_Field_Configuration__mdt) and Relationship Role Configuration (mvn__PJN_Relationship_Role_Configuration__mdt) metadata records, as detailed in the "Steps to reproduce" section below. |
Steps to reproduce | Scenario 1: When an admin creates a Relationship Role Configuration metadata record for a business account and a person account and a user adds the Business Account and Person Account records to a Care Plan (Case) record, Care Connect creates a new Account Contact Relationship record with the specified role. If the admin then updates the name of the role on the Relationship Role Configuration metadata record and the user modifies and saves the Care Plan record, Care Connect tries to create another Account Contact Relationship record with the updated role. However, because an Account Contact Relationship record already exists for the same Business Account and Person Account records, an error is thrown. Create a Case Field Configuration metadata record for a business account. Alternatively, you may use the out-of-the-box Organization (PJN_Organization) metadata record. Create another Case Field Configuration metadata record for a person account (i.e., contact). Alternatively, you may use the out-of-the-box Patient (PJN_Patient) metadata record. Create a Relationship Role Configuration metadata record for the two Case Field Configuration metadata records created in steps 1 and 2. Make sure to populate the Role (mvn__PJN_Role__c) field. Alternatively, you may use the out-of-the-box Patient-Organization (Patient_Organization) metadata record. Ensure that the Case field that is referenced on the Case Field API Name (mvn__PJN_Case_Field_API_Name__c) field of the Case Field Configuration metadata record from step 1 is available either as a tile in Account Search or as a key field on the Care Plan record page. If you are using the out-of-the-box metadata records in steps 1-3, this is the Organization (mvn__PJN_Organization__c) field on the Case object. Enroll a patient into a care plan and populate the Case field from step 4 with a business account either through Account Search or on the Care Plan record page. Update the Role field on the Relationship Role Configuration metadata record from step 3. Update the care plan from step 5 but do not change the patient or the business account. Note the error message that appears when you click Save: "An error occurred while trying to update the record… This contact already has a relationship with this account…"
Scenario 2: When an admin creates two or more Relationship Role Configuration metadata records for the same business account and person account and a user adds the Business Account and Person Account records to a Care Plan record, Care Connect tries to create multiple Account Contact Relationship records for the same Business Account and Person Account records. As a result, an error is thrown. Create a Case Field Configuration metadata record for a business account. Alternatively, you may use the out-of-the-box Organization (PJN_Organization) metadata record. Create another Case Field Configuration metadata record for a person account (i.e., contact). Alternatively, you may use the out-of-the-box Patient (PJN_Patient) metadata record. Create a Relationship Role Configuration metadata record for the two Case Field Configuration metadata records created in steps 1 and 2. Make sure to populate the Role (mvn__PJN_Role__c) field. Alternatively, you may use the out-of-the-box Patient-Organization (Patient_Organization) metadata record. Create another Relationship Role Configuration metadata record with the same two Case Field Configuration metadata records created in steps 1 and 2. Make sure to populate the Role field with a different value from step 3. Ensure that the Case field that is referenced on the Case Field API Name (mvn__PJN_Case_Field_API_Name__c) field of the Case Field Configuration metadata record from step 1 is available either as a tile in Account Search or as a key field on the Care Plan record page. If you are using the out-of-the-box metadata records in steps 1-3, this is the Organization (mvn__PJN_Organization__c) field on the Case object. Enroll a patient into a care plan and populate the Case field from step 5 with a business account either through Account Search or on the Care Plan record page. Note the error message that appears. If you set the Case field through Account Search, the error message says, "Insert failed… This contact already has a relationship with this account…" If you set the Case field on the Care Plan record page, the error message says, "An error occurred while trying to update the record… This contact already has a relationship with this account…"
|