function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to write trigger for JOIN Object?

Hi Friends,

I have created a custom object which is join to Both Account and Contact.Now i have to Add a trigger that when a join object is inserted, the trigger will copy the billing street address from the related Account to the other streets address on the related Contact.Pls Help me out how to write this...........
































you can create an after insert trigger on the JoinObject. what is the problem you are facing while writing the trigger?




Problem with How to get Account & Contact field deails related to particular custom object field?Pls share me how to do it.....Thanks for spending ur valuable time 


Join means that you have created two master-detail or lookup fields on the JOIN object. While writing the trigger on the join object you can easily access the id of the account and the contact records which are related through the JOIN record. So you can query like this


Select Id, Account__c, Contact__c from Join__c where id in etc...


I tried with that but getting error while accessing fields from custom object with relation name.......Could you pls spend some time to write it?pls i will be thankfull to you.


I would need to know the api names of the fields that you have created on the Join object and the api name of the join object itself.



First of all thanks for ur interest.I wil explain in detail.I have created one custom object named as Detail which is detail to Account and contact.Now my task is when i insert record into Detail object,related Account object field data should be copied to related Contact field.{field is billing street address(Account) to other streets address } .

Richa KRicha K



You can't do this using trigger. Instead, use a workflow rule.