0

Error: Compile Error: unexpected token: 'List' at line 6 column 1

trigger AbortInsert on Adder__c (before insert)
{


System.debug('****************************************');
 List& amp;lt;Adder__c> adders = Trigger.new;



    for (Adder__c adder: adders)
    {
        if(AdderExt.fakeSave == true)
        {
            // AdderExt controls an editor that should only work on one row at a time
            System.assertEquals(adders.size(), 1);

            // Provide the evaluation results to the line item controller
            AdderExt.evaluationResults = adder;

            System.debug('adder='+adder);

            // Abort the save
            adder.addError('Throwing error to prevent DML for this formula only evaluation');
        }
    }
}
0

I'm not sure why you're using a List to put Trigger.new in, this seems like a waste of memory to me. Also, this line seems incorrect in general (did you try changing it to a HTML-friendly equivalent?):

List& amp;lt;Adder__c> adders = Trigger.new;

Please replace your code with:

trigger AbortInsert on Adder__c (before insert) 
{

    System.debug('****************************************');

    for (Adder__c adder: Trigger.new)
    {
        if(AdderExt.fakeSave == true)
        {
            // AdderExt controls an editor that should only work on one row at a time
            System.assertEquals(Trigger.new.size(), 1);

            // Provide the evaluation results to the line item controller
            AdderExt.evaluationResults = adder;

            System.debug('adder='+adder);

            // Abort the save
            adder.addError('Throwing error to prevent DML for this formula only evaluation');
        }
    }
}

As you can see we now use Trigger.new.size() directly in the for loop. Inside the for-loop we use Trigger.size instead of adders.size().

3
  • Compile Error: Variable does not exist: Trigger at line 15 column 33 – user5633 Jan 21 '15 at 9:09
  • I am getting error for your code – user5633 Jan 21 '15 at 9:10
  • I've updated my code. If it still doesn't work, please paste the line that gives the error in here if you've changed anything. It seems that line 15 doesn't use the Trigger-variable at all. – Koen Wesselman Jan 21 '15 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.