Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger Example123 on Case (before insert, before update) {
- public List <Account> lstAcc = new List<Account>();
- public Id accountOwner;
- /* For (Case c : Trigger.new){
- lst.add(c.id);
- }*/
- //system.debug('******' +lst);
- list<case> cc= [select id,AccountId, case.Account.OwnerId, AdditionalCon__c from case where id =: Trigger.new];
- system.debug('******' +cc);
- for(Case cas : cc){
- lstAcc = [Select Id, Ownerid from Account where Id =: cas.AccountId];
- }
- for (Case c: cc){
- // system.debug('c.account.Ownerid**********'+c.account.Ownerid);
- if((Trigger.isInsert || Trigger.isUpdate ) && Trigger.isBefore ){ //Before Insert
- //system.debug('c.account.Ownerid**********'+c.account.Ownerid);
- if(c.AdditionalCon__c ==null ){
- for(Account a : lstAcc ){
- if(c.AccountId == a.Id){
- accountOwner = a.OwnerId;
- }
- }
- system.debug('AccountOwner**********'+accountOwner);
- c.AdditionalCon__c = accountOwner;
- system.debug('AdditionalCon :' +c.AdditionalCon__c);
- }
- }
- //lst.add(c);
- }
- //update lst;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement