Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public class UpdateAccountAddresses {
  2. Map<id,account>updateShippingAddressMap =new Map<id,Account>{};
  3. Map<id,Account> updateBillingAddressMap =new Map<id,Account>();
  4. set<id>AccountSetId=new Set<Id>{};
  5. list<contact> conlist=new list<contact>();
  6.  
  7. public void RunOnUpdate(map<id,Account>NewMap,Map<id,Account>OldMap){
  8. for(id aid:newmap.keySet()){
  9. AccountSetId.add(aid);
  10. account newAccount=(Account)newmap.get(aid);
  11. account OldAccount=(Account)oldmap.get(aid);
  12. if(newAccount.ShippingCountry!=oldAccount.ShippingCountry ||
  13. newaccount.ShippingCity!=oldAccount.ShippingCity )
  14. {
  15. contact con=new contact(lastname='testforAcc',accountid=aid);
  16. conList.add(con);
  17. }
  18. }
  19. insert conlist;
  20. }
  21. }
  22.  
  23. @isTest
  24. public class UpdateAccountAddresses_Test {
  25.  
  26. static testmethod void runTest(){
  27. Account acc=new Account(name='testAccount',ShippingCity='Delhi',ShippingCountry='India');
  28. insert acc;
  29. acc.ShippingCity='jaypur';
  30. update acc;
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement