Skip to main content
Good day, i have managed to create this trigger that rolls up won opportunities for partners and then attaches the total value on the partners account page.  But i guess i need to create a test class so i can test for code coverage.  i am having a hard time starting this test class, can someone help.

 

here is the code for the trigger.

 

trigger TotalOppVerifiedValue on Account (before update) 

 

{

 

List<Opportunity> opplist=new List<Opportunity>();

 

List<Double> crr=new List<Double>();

 

 Double TotalAmt=0;

 

 for (Account acc:Trigger.new)

 

    {

 

  //   System.debug('######@@@@@@@@@'+acc);

 

  //List<Partner> prn=[Select Opportunityid from Partner where AccountfromId=:acc.id];

 

          for(Partner prn1:[Select Opportunityid from Partner where AccountfromId=:acc.id])

 

          {

 

          // System.debug('!!!!!@@@@@@@@@'+prn1);

 

          //  opplist.add(prn1. Opportunityid )

 

             for (Opportunity opp:[Select Verified_Value__c from Opportunity where id=:prn1.Opportunityid ])

 

             {

 

             

 

           //   System.debug('$$$$$$$$$$$$@@@@@@@@@'+opp);

 

               crr.add(opp.Verified_Value__c);

 

               

 

               // acc.Total_Verified_Value_for_Opps__c=opp.Verified_Value__c

 

             }

 

        //  System.debug('@@@@@@@@@'+crr);

 

          

 

          }

 

             for(integer i=0;i<crr.size();i++)

 

                {

 

                   TotalAmt += crr[i];

 

                }

 

        acc.Total_Verified_Value_for_Opps__c=TotalAmt ;

 

    }

 

   

 

   

 

   

 

 

}

1 answer
0/9000