You need to sign in to do that
Don't have an account?
Malhar_Ulhas_Agale
How to delete Accountcontact relationship record from apex ?
Hi i have desinged a vf page to add multiple accounts records for a particular contact using related accounts at same time.
But now i also have to delete existing relationships in the related accounts for the contact at the same time.
Since the account contact relationship object doesnt have an ID field, also the account ID and contactID lookup are not editable fields.
So how can i delete the accountcontactrelationship record without deleting the associated contact or account ?
Please let me know.
Thanks,
Malhar Ulhas Agale.
But now i also have to delete existing relationships in the related accounts for the contact at the same time.
Since the account contact relationship object doesnt have an ID field, also the account ID and contactID lookup are not editable fields.
So how can i delete the accountcontactrelationship record without deleting the associated contact or account ?
Please let me know.
Thanks,
Malhar Ulhas Agale.
Here bit confusing ,your requirmenet is to delete the relationship or you want to reparent means you need to trasfer the contacts of account a to account B .
The relationship field between Account and Contact is AccountId ,
1. If you want to remove the relationshipship then make the AccountId=null ,
2.If you want to reparent or trasfer the contacts from one account to another then simply update th eAccountId field with different Account's Id field .
let me know if it helps .
Thanks
Manoj
Hi Manoj,
Thanks for your answer. But i figured out how to delete the records of accountcontactrelation object. I just queried the records of accountcontact relation for the particular contact and compared whether it contacined the certain account id. Based on it i populated it in an list<accountcontactrelation> , then fired the delete DML operation.
In this way i solved the problem.Following is the code which i used: