• prashanth g 10
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

hi,
i am new to salesfoce here i got scenario like populate total revenue  in amount filed in account record which is having number opportunity childs

i am providing sample format also 

thanks in advance
trigger contactTrigger on opportunity ( after insert, after update, after delete, after Undelete) {
    Set<ID> accIdSet = new Set<ID>();
    
    // After Insert 
    if(Trigger.isAfter){   
        if(Trigger.isUndelete || Trigger.isInsert){
            for(opportunity c : Trigger.New){
                if(c.AccountId != Null){
                    accIdSet.add(c.AccountID);
                }
            }   
        }
        
        if(Trigger.isDelete){
            for(opportunity c : Trigger.Old){
                if(c.AccountId != Null){
                    accIdSet.add(c.AccountID);
                }
            }  
        }
    }
    
    
    List<Account> accList = [SELECT ID, No_of_opportunities__c, (SELECT Id , revenueFROM opportunites) FROM Account WHERE Id IN :accIdSet];
    
    if(accList.size() > 0 ){
        for(Account a : accList){           
            a.No_of_opportunities__c = a.contacts.size()    //which one i need to fill here;
        }
        update accList; 
    }
    
}

i am new to salesfoce and have query like this

list<account> accList= [select id, name,  accountNumber (select id, firtName, LastName, phone from contacts) from account];

now i want to display records of account name in one system.debug  and display firstName and phone values in another system.debug i am confusing nested for loop could any help me on this

i am new to salesfoce and have query like this

list<account> accList= [select id, name,  accountNumber (select id, firtName, LastName, phone from contacts) from account];

now i want to display records of account name in one system.debug  and display firstName and phone values in another system.debug i am confusing nested for loop could any help me on this