You need to sign in to do that
Don't have an account?
manjunath vivek
Error: Compile Error: Invalid field I_am_Awesome__c for SObject Opportunity at line 13 column 7
trigger Winning on Opportunity (before update) {
for (Opportunity opp : Trigger.new) {
// Access the "old" record by its ID in Trigger.oldMap
Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
// Trigger.new records are conveniently the "new" versions!
Boolean oldOppIsWon = oldOpp.StageName.equals('Closed Won');
Boolean newOppIsWon = opp.StageName.equals('Closed Won');
// Check that the field was changed to the correct value
if (!oldOppIsWon && newOppIsWon) {
opp.I_am_Awesome__c = true;
}
}
}
when I try to save the above code, iam getting error message Error Error: Compile Error: Invalid field I_am_Awesome__c for SObject Opportunity at line 13 column 7
I have I_am_Awesome__c custom field in the oppurtunity object still I am getting the message, can some one help me on this?
for (Opportunity opp : Trigger.new) {
// Access the "old" record by its ID in Trigger.oldMap
Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
// Trigger.new records are conveniently the "new" versions!
Boolean oldOppIsWon = oldOpp.StageName.equals('Closed Won');
Boolean newOppIsWon = opp.StageName.equals('Closed Won');
// Check that the field was changed to the correct value
if (!oldOppIsWon && newOppIsWon) {
opp.I_am_Awesome__c = true;
}
}
}
when I try to save the above code, iam getting error message Error Error: Compile Error: Invalid field I_am_Awesome__c for SObject Opportunity at line 13 column 7
I have I_am_Awesome__c custom field in the oppurtunity object still I am getting the message, can some one help me on this?
If you want to give true value to Awesome__c, than give it as,
opp.Awesome__c= 'true';
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
All Answers
Have you check API name of the field I_am_Awesome__c?
It may contain some spelling mistake.
I hav changed the name to Awesome and tried the code
opp.Awesome__c= true;
Now Iam getting the different error message.
Error Error: Compile Error: Illegal assignment from Boolean to String at line 13 column 7
If you want to give true value to Awesome__c, than give it as,
opp.Awesome__c= 'true';
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
It worked.I have changed the data type to check box.