Posts

Showing posts from March, 2015

Update Contact Mailing Address with Account Billing Address on Custom Button

Image
Requirement:  On Account Detail Page is there is a Custom Button named Copy Address, When We click on this button then Billing Address of Account record is updated in all Contacts of that Account in Mailing Address. Solution : There are 3 solution  1) First one is write the trigger and invoke at custom button 2)  Call javascript code on Custom Button 3) Invoke Web service on Custom Button. I am explaining 3rd . Firstly Create a Apex Class: Class Name : UpdateContactAddress global class UpdateContactAddress {    webservice static String processDetails(String accID){          List<Account> lstacc =[select id,BillingCity,BillingCountry,BillingState from Account where ID =:accID limit 1];      system.debug('acc====='+lstacc);      List<Contact> lstofcont =[select id ,MailingCity,MailingCountry,MailingState,MailingPostalCode,MailingStreet       from contact where AccountID =: accID];             system.debug('lstofcont ====='+lstofcont);