Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UpdateAccountAddresses {
- Map<id,account>updateShippingAddressMap =new Map<id,Account>{};
- Map<id,Account> updateBillingAddressMap =new Map<id,Account>();
- set<id>AccountSetId=new Set<Id>{};
- list<contact> conlist=new list<contact>();
- public void RunOnUpdate(map<id,Account>NewMap,Map<id,Account>OldMap){
- for(id aid:newmap.keySet()){
- AccountSetId.add(aid);
- account newAccount=(Account)newmap.get(aid);
- account OldAccount=(Account)oldmap.get(aid);
- if(newAccount.ShippingCountry!=oldAccount.ShippingCountry ||
- newaccount.ShippingCity!=oldAccount.ShippingCity )
- {
- contact con=new contact(lastname='testforAcc',accountid=aid);
- conList.add(con);
- }
- }
- insert conlist;
- }
- }
- @isTest
- public class UpdateAccountAddresses_Test {
- static testmethod void runTest(){
- Account acc=new Account(name='testAccount',ShippingCity='Delhi',ShippingCountry='India');
- insert acc;
- acc.ShippingCity='jaypur';
- update acc;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement