+ Start a Discussion
@taani.ax1426@taani.ax1426 

Urgent requirement, pls help

Hi All,

 

I have a requirement, there is two object, one standard(Account), one custom(Deal), and look up relation is there.

I made one VF page on Account, and there is lookup for Deal name, what my requirement is:

 

On the selection of particular deal name thru lookup ,few field from "Deal" should be auto populated in some field of "Account".

 

Eg:

There is Phone number in deal object, when user choose Deal1, then phone number associate with deal1 should populate in Phone number field in Account object.

 

Please help in this, and provide sample code.

 

Regards,

Taani

 

 

PrakashbPrakashb

You can try the below code

 

trigger SiteAddressTrigger on Contact (before insert){
 

 Set<Id> conIds = new Set<Id>();
 
  Map<Id, Site_Address__c> siteMap = new Map<Id,Site_Address__c>();
 

 for(Contact c : trigger.new){

    conids.add(c.ID);

 }

 

for(Site_Address__c sc:  [select Id,ContactId,Shipping_State_Province__c from Site_Address__c where ContactId IN: conIds]){

  sitemap.put( sc.ContactID,sc);

}
 for(Contact c : Trigger.New){

     c.MailingState = sitemap.get(c.ID) .Shipping_State_Province__c;
   
}

 

}