0

I am trying to construct a SOQL query to filter records in salesforce by product category, year and reporting period, using the R package RForcecom (read more about RForcecom here).

At the moment, attempting this is throwing the error message: "Bind variables only allowed in Apex code". I've seen posts referencing errors like this in other languages besides R, such as this StackOverflow post from a couple of years ago, but am having trouble translating the answers into code that would work in R.

Here's a shortened example of a query that leads to this error:

    SELECT ID,Account__c,Product_Family__c,Transaction_Type__c
    FROM Licensee_Report__c 
    WHERE Year__c = 2016 AND Reporting_Period__c = Q2

All of these field and object names refer to real fields/objects and are the correct API names for our salesforce instance. This is just an example and serves to highlight the kind of multi-object query I am hoping to make.

Normally, RForcecom lets you use the function rforcecom.query() to run SOQL queries after having logged into the API within R. See the link above for more.

Any ideas are much appreciated!

1

Clauses must be properly quoted. Assuming Reporting_Period__c is some sort of text field (text, picklist, etc), you need to quote it:

SELECT ID,Account__c,Product_Family__c,Transaction_Type__c
FROM Licensee_Report__c 
WHERE Year__c = 2016 AND Reporting_Period__c = 'Q2'

The same also applies if Year__c is some sort of text value. Numbers, dates, and checkboxes should not be quoted.

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.