I have a custom object called Account Affiliations which is a junction object between two accounts. Below is the schema of the object.
Object Name: Account_Affiliations__c Custom fields: 1) Account to (Account_to__c)--lookup relationship 2) Account From (Account_from__c)-- lookup relationship 3) Department (department__c) --picklist
lets assume we have two accounts, Account A, Account B. Lets create an account affiliation record between these two. Every time a account_affiliation__c record is inserted, we have to create another affiliation record and have to swap the account to and account from Ids in the new record.
Record 1: Account From: Account A, Account To: Account B, Department: manufacturing
Record 2: Account From: Account B, Account To: Account A, Department: manufacturing (this should be automatically created)
how to accomplish this using a trigger to handle insert, update and delete? any pointers will be highly appreciated.