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
mail2ghani1.3921762673905103E12mail2ghani1.3921762673905103E12 

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.

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.
ShashForceShashForce
Hi,

This should help:

trigger updateConAdrFromAcc on join_object__c (after insert) {
    set<Id> Ids = new set<Id>();
    map<Id,string> AccAdrMap = new map<Id,string>();
    for(join_object__c j:trigger.new){
        Ids.add(j.Id);
    }
    for(join_object__c jo:[select Id, account__r.BillingStreet from join_object__c where Id in :Ids]){
        AccAdrMap.put(jo.Id,jo.account__r.BillingStreet);
    }
    list<Contact> conlist = new list<Contact>();
    for(join_object__c joc:trigger.new){
        Contact con = new Contact();
        con.Id = joc.contact__c;
        con.OtherStreet = AccAdrMap.get(joc.Id);
        conlist.add(con);
    }
    if(conlist.size()>0){
        update conlist;
    }
}

If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.

Thanks,
Shashank