function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gbrown17gbrown17 

custom controller - unexpected token 'apex.pages.currentpage'

Hi,


I'm having difficulty understanding where I went wrong when creating the apex class.  I'm getting an error on line 12 - unexpected token: 'ApexPages.currentPage'.  

 

Can someone shed some light on this for me?


Thanks,

Greg

public class aseAuditPDFController
{
	public Credit__c__c getCredit()
    {
        //Retrieve Credit Application based on Id parameter of this page
        return [Select Id,
                Credit__c.Financial_Data__c,
                Credit__c.Forecast_Sales_per_Month__c,
                Credit__c.Customer_Type__c
                from Credit__c j
                where Id= 
ApexPages.currentPage().getParameters().get('id')];

    }
}

 

Best Answer chosen by Admin (Salesforce Developers) 
jayjaysjayjays

Hi Greg,

 

when referencing a non-literal in a SOQL query, you need to put a colon before the variable, like below.

 

return [Select Id,
                Financial_Data__c,
                Forecast_Sales_per_Month__c,
                Customer_Type__c
                from Credit__c
                where Id=:ApexPages.currentPage().getParameters().get('id')];

All Answers

jayjaysjayjays

Hi Greg,

 

when referencing a non-literal in a SOQL query, you need to put a colon before the variable, like below.

 

return [Select Id,
                Financial_Data__c,
                Forecast_Sales_per_Month__c,
                Customer_Type__c
                from Credit__c
                where Id=:ApexPages.currentPage().getParameters().get('id')];
This was selected as the best answer
gbrown17gbrown17

Thanks it worked!