Search code examples
ruby-on-rails-4salesforcesoqldatabasedotcom-gem

Resforce SOQL Query Error Bind variables only allowed in Apex code


I have a controller action that needs to take the Account ID of the logged in user (parent) and make a SOQL query to find all of children associated with the parent. I receive the following error:

Bind variables only allowed in Apex code

After searching around I've learned that I can't use a variable in my SOQL query. However, I am looking for some help as to pull multiple children on a parent using a dynamic parent ID. My query currently looks like this:

@loanparts = client.query("select Loan_Risk__c from Loan_Part__c where Account__c = @account.Account__c")

Solution

  • Change your query to pass accountid as string, I don't know which programming language are you using. Please try this.

    @loanparts = client.query("select Loan_Risk__c from Loan_Part__c where Account__c ='+AccountId+'")