I'm trying to create a relationship between Person Account and Contact. I'm doing it in Apex and using AccountContactRelation(ACR) object. I'm taking information from the Order and want to assign it to the ACR ContactId and AccountId, but not sure how it is done. Also, I want to be sure that the ACR does not already exist.
Contact firstSigner = configureContactAsSigner(eventData.salesContract.additionalContractSigners[0], ord.Business_Account__c);
ord.Contract_signer_1__r = new Contact(Unique_Email__c = firstSigner.Unique_Email__c);
dw.contacts.add(firstSigner);
List<AccountContactRelation> acrList = [SELECT AccountId, ContactId FROM AccountContactRelation];
for (AccountContactRelation acrRel : acrList) {
if (acrRel.AccountId != ord.Business_Account__c && acrRel.ContactId != ord.Contract_signer_1__r) {
AccountContactRelation acr = new AccountContactRelation();
acr.AccountId = ord.Business_Account__c;
acr.ContactId = ord.Contract_signer_1__r.Unique_Email__c;
dw.acr.add(acr);
}
}