You need to sign in to do that
Don't have an account?
Thomas Caillet
My Opportunity trigger doesn't recognize my standard fields on sandbox
Hello,
I need your help about something strange on my sandbox:
I want to write a trigger that create one case for each opportunity line items when my opportunity is "Closed Won".
But I'm a junior developper so I started to write just the case creation when opportunity is "Closed Won". But I've got this error:
Error: Compile Error: Variable does not exist: StageName ...
I think the trigger don't recognize all fields.
Please tell me what I'm doing wrong. Thanks
Here is my "simple" code :
trigger createNewCase on Opportunity (before insert, before update) {
List<Case> listcase = new List<Case>();
for(Opportunity o: Trigger.new)
{
if ( o.StageName == 'Closed Won' )
{
listCase.add(
new Case(
Priority = 'Medium',
Status = 'New'));
}
}
if(listcase.size()>0)
{
insert listcase;
}
}
I need your help about something strange on my sandbox:
I want to write a trigger that create one case for each opportunity line items when my opportunity is "Closed Won".
But I'm a junior developper so I started to write just the case creation when opportunity is "Closed Won". But I've got this error:
Error: Compile Error: Variable does not exist: StageName ...
I think the trigger don't recognize all fields.
Please tell me what I'm doing wrong. Thanks
Here is my "simple" code :
trigger createNewCase on Opportunity (before insert, before update) {
List<Case> listcase = new List<Case>();
for(Opportunity o: Trigger.new)
{
if ( o.StageName == 'Closed Won' )
{
listCase.add(
new Case(
Priority = 'Medium',
Status = 'New'));
}
}
if(listcase.size()>0)
{
insert listcase;
}
}
Select StageName from opportunity
I don't understand why I can't save my trigger :/
Above code looks good..Its working fine in my DEV environment.
Scenario: Whenever opportunity is created/updated with stage name as Closed Won. New case will get created ..
let me know exact error message which you are geeting.
Thank you,
Anil
Thanks to you