Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
Can anyone plz tell what is the error.. I totaaly got pissed now... it shows error

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
  1. Sep 13, 2015, 2:33 PM
    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 :

     

    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 if(trigger.isUpdate && f.Fees__<1500 )

    {

    f.addError('greater than 1500');

    }

    }

    }

    I have done modification at line no. 10.

    Regards,

    Abhishek
0/9000