Guest User

Untitled

a guest
Feb 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Trigger fetchaddress on Account (before insert , before update) {
  2. set<id> acid = new set<id>();
  3. for(Account ac: Trigger.new){
  4. if (ac.id != null)
  5. acid.add(ac.id);
  6. }
  7. Map<id,Address__c> fetch = new Map<id,Address__c>([select id,name,City__c,Country__c,Postal_Code__c,State__c,Billing_Street__c from Address__c where id in : acid]);
  8.  
  9. for(Account a : Trigger.new){
  10. Address__c ad = fetch.get(a.id);
  11.  
  12. if(A.id !=null)
  13.  
  14. a.Billingstreet = ad.Billing_Street__c;
  15. a.Billingcity = ad.City__c;
  16. a.Billingstate = ad.State__c;
  17. a.BillingPostalcode = ad.Postal_Code__c;
  18. a.Billingcountry = ad.Country__c;
  19. }
  20. }
Add Comment
Please, Sign In to add comment