You need to sign in to do that
Don't have an account?
Test class for a trigger
Hi All
Can you please help me out in writter a test class for the following Trigger. Appreciate your help in advance
trigger CaseUpadate on Opportunity (after update)
{
List <Case> caseList;
List <Id> oppIdList = new List <Id>();
for(Integer i=0; i<Trigger.new.size(); i++)
{
if (Trigger.new[i].StageName != Trigger.old[i].StageName && (Trigger.new[i].StageName == 'Closed Won' || Trigger.new[i].StageName == 'Closed - Dead/Lost'))
oppIdList.add(Trigger.new[i].Id);
}
caseList = [select Id, Opportunity_closed_won__c from Case where Opportunity__c in :oppIdList];
if (caseList.size() > 0)
{
for(Case c : caseList)
{
if (c.Opportunity_closed_won__c != true)
c.Opportunity_closed_won__c = true;
}
update caseList;
}
}