Skip to content

Commit

Permalink
Changes in 'createAddressFromContactAndSetCurrentAddressLookupId' met…
Browse files Browse the repository at this point in the history
…hod of ContactAdapter.cls
  • Loading branch information
salesforce-suyash-more committed Oct 1, 2024
1 parent 2aa4354 commit 6fd0675
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions force-app/main/adapter/in/sobjects/contact/ContactAdapter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,7 @@ public inherited sharing class ContactAdapter extends fflib_SObjects2 {

// Add the new address to be inserted
contactAddressesToInsertByContact.put(contact, newAddress);

// Link the new address to the contact's Current Address field
contact.Current_Address__c = newAddress.Id;

}
else if (contactAddressHasAddressMatch(existingAddressFromContact)) {
updateContactAddressFromExistingAddress(contact, existingAddressFromContact);
Expand All @@ -696,6 +694,16 @@ public inherited sharing class ContactAdapter extends fflib_SObjects2 {
}
// Insert the new addresses created for contacts with Address Override
insertContactAddresses(contactAddressesToInsertByContact);

for (Contact contact : contactAddressesToInsertByContact.keySet()) {
Address__c insertedAddress = contactAddressesToInsertByContact.get(contact);
if (insertedAddress != null && insertedAddress.Id != null) {
contact.Current_Address__c = insertedAddress.Id; // Now set the address ID
}
else
contact.Current_Address__c = null;

}
}

private Set<Contact> getAddressCreationQueueBeforeUpdate() {
Expand Down

0 comments on commit 6fd0675

Please sign in to comment.