Error: Compile Error: unexpected token: '{' at line 11 column 4
trigger feesCheck on Test__c (before insert, before update)
{
for(Test__c f : trigger.new)
{
if(trigger.isInsert && f.Fees__c < 1000)
{
f.addError('incorrect data 1000');
}
else(trigger.isUpdate && f.Fees__<1500 )
{
f.addError('greater than 1500');
}
}
}
1 answer
Hi,Just a little mistake but please take care of this thing in future that you cannot add a condition in else statement.Please correct your code as follows :
I have done modification at line no. 10.Regards,Abhishektrigger feesCheck on Test__c (before insert, before update)
{
for(Test__c f : trigger.new)
{
if(trigger.isInsert && f.Fees__c < 1000)
{
f.addError('incorrect data 1000');
}
else if(trigger.isUpdate && f.Fees__<1500 )
{
f.addError('greater than 1500');
}
}
}