Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. trigger Example123 on Case (before insert, before update) {
  2.  
  3. public List <Account> lstAcc = new List<Account>();
  4. public Id accountOwner;
  5. /* For (Case c : Trigger.new){
  6. lst.add(c.id);
  7. }*/
  8. //system.debug('******' +lst);
  9. list<case> cc= [select id,AccountId, case.Account.OwnerId, AdditionalCon__c from case where id =: Trigger.new];
  10. system.debug('******' +cc);
  11.  
  12. for(Case cas : cc){
  13. lstAcc = [Select Id, Ownerid from Account where Id =: cas.AccountId];
  14. }
  15. for (Case c: cc){
  16. // system.debug('c.account.Ownerid**********'+c.account.Ownerid);
  17. if((Trigger.isInsert || Trigger.isUpdate ) && Trigger.isBefore ){ //Before Insert
  18. //system.debug('c.account.Ownerid**********'+c.account.Ownerid);
  19. if(c.AdditionalCon__c ==null ){
  20.  
  21. for(Account a : lstAcc ){
  22. if(c.AccountId == a.Id){
  23. accountOwner = a.OwnerId;
  24. }
  25. }
  26.  
  27. system.debug('AccountOwner**********'+accountOwner);
  28. c.AdditionalCon__c = accountOwner;
  29. system.debug('AdditionalCon :' +c.AdditionalCon__c);
  30. }
  31. }
  32. //lst.add(c);
  33. }
  34.  
  35. //update lst;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement