You need to sign in to do that
Don't have an account?
nitin sharma 366
Error when an opportunity trigger code written in a class.
Hi All,
I am only trying to update a check box on an Opp object when stagename is changed to closed won but i get the following error
Compile Error: Variable does not exist: stagename at line 10 column 32
I want to write most of the code in the class not in the trigger .So please tell me how can i write this code in the class.
public class UpdateOppCheckBox
{
public static void UpdateOpp(List<opportunity>listOpps)
{
//list<opportunity>updte=new list<opportunity>();
for(opportunity opp1:ListOpps)
{
if(trigger.oldmap.get(opp1.id).stagename!=trigger.newmap.get(opp1.id).stagename && opp1.stagename=='closed won')
{
opp1.Update_Checkbox__c=true;
}
}
}
}
I am only trying to update a check box on an Opp object when stagename is changed to closed won but i get the following error
Compile Error: Variable does not exist: stagename at line 10 column 32
I want to write most of the code in the class not in the trigger .So please tell me how can i write this code in the class.
public class UpdateOppCheckBox
{
public static void UpdateOpp(List<opportunity>listOpps)
{
//list<opportunity>updte=new list<opportunity>();
for(opportunity opp1:ListOpps)
{
if(trigger.oldmap.get(opp1.id).stagename!=trigger.newmap.get(opp1.id).stagename && opp1.stagename=='closed won')
{
opp1.Update_Checkbox__c=true;
}
}
}
}
Greetings to you!
Please use the below code:
Apex Trigger: Apex Class: Hope this will help you. If does then mark it as the best answer so it will also help others in the future.
Many Thanks,
Sunil Rathore