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개
If you want someone to give you the full code, post this question in developer.force.com forums. If you'd like to try to figure it out on your own, this is where I started: http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods