0

I keep getting an error

Error: Compile Error: expecting a colon, found 'accountId' at line 11 column 36

Hotel_Acct__c is a lookup to Account ID so this should work. Already tried the SOQL query in Dev Console and it worked fine.

public  class summRes
{
    public Id accountId {get;set;}
    public List<Reservation__c> getres()
    {
        List<Reservation__c> res;
        oppty = [SELECT Contact__c, ClubID_in_Reservation__c, Name, Arrival_Date__c FROM Reservation__c 
                WHERE  Arrival_Date__c = THIS_YEAR 
                AND Cancellation_Ref__c = NULL 
                AND ClubID_in_Reservation__c != NULL
                AND Hotel_Acct__c = accountId];
        return res;
    }
}

Thanks in advance.

1
  • 1
    Are you still having issues or did the below answer solve your problem. If it did solve your problem etiquette would be to mark it as the accepted solution so others having the same problem can find answers
    – Eric
    Commented Sep 6, 2016 at 21:00

1 Answer 1

9

The problem is exactly what the compile error is describing. When binding a variable in SOQL, a colon must be prepended to the variable:

public  class summRes
{
    public Id accountId {get;set;}
    public List<Reservation__c> getres()
    {
        List<Reservation__c> res;
        oppty = [SELECT Contact__c, ClubID_in_Reservation__c, Name, Arrival_Date__c FROM Reservation__c 
                WHERE  Arrival_Date__c = THIS_YEAR 
                AND Cancellation_Ref__c = NULL 
                AND ClubID_in_Reservation__c != NULL
                AND Hotel_Acct__c = :accountId];
        return res;
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .