Question

I am getting error "unexpected token List " while compiling the following code

trigger Lead_Casecloseafter on Lead (after update) {
    // Collect ODST leads
    id vRecordTypeId = [select Id from RecordType where name='ODST_Leads'];
    set<id> vSetCaseId= new set<id>();

    for (Lead vLead:trigger.new)
    {
        if (vLead.RecordTypeId == vRecordTypeId && vLead.IsConverted == true)
            vSetCaseId.add (vLead.ODST_Case__c);
        }
    }

    // Looking up associated Case
    List <Case> vLstcase = new List ([select id,name,Case_Number__c,Status from            ODST_Case__c where ID IN:vSetCaseId]);

    for (Case vCase:vLstcase)
    {   
        vCase.Status == 'Closed';

        if(!vLstcase.isempty())
            update vLstcase; 
    }
}
Was it helpful?

Solution

Judging by the rest of the code, it looks like you're missing an opening brace ({) after this line:

if (vLead.RecordTypeId == vRecordTypeId && vLead.IsConverted == true)

The closing brace immediately after the if closes the function (since there was no block opened for the if), causing the List line to be in an invalid context.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top