We are using Jitterbit to query records from Salesforce, but we are running into an issue. In the query condition statement I am comparing two fields from the Salesforce table. When I go to test the query, it gives me the error "Bind variables only allowed in Apex Code [MALFORMED QUERY]".
Here is an example of the query:
SELECT Id FROM Price_Agreement_Item__c WHERE Approved_Date__c > Last_Upload_Date__c
The fields Approved_Date__c
and Last_Upload_Date__c
are both contained in Salesforce table Price_Agreement_Item__c
. How does one create a SOQL statement that conditions the select statement comparing two fields in the table?
Any help is appreciated.
Thank you in advance.
A bind variable is an Apex variable that you use in a SOQL query. Use bind variables as placeholders for specific values to be provided later. This isn't a new concept. In Object-Oriented Programming for Admins, you learned about using a parameter as a placeholder in a method.
Salesforce does not allow direct field to field comparison in SOQL query. To achieve this you can create a formula field that will compare fields and return a value (such as true or false) which you can use in a WHERE clause.
SOQL stands for Salesforce Object Query Language. You can use SOQL to read information stored in your org's database. SOQL is syntactically similar to SQL (Structured Query Language). You can write and execute a SOQL query in Apex code or in the Developer Console's Query Editor.
In addition to what Daniel Ballinger said, the Soap API also does not allow the 'IN' clause in SOQL queries. It's stupid, but then again, that's 95% of Salesforce.
Another way this can happen is if you copy your query to the command line and run it without escaping the quotes around any string constants.
E.g., this:
curl -X GET https://x.salesforce.com/services/data/v31.0/query?q=SELECT%20COUNT\(\)%20FROM%20YourObj%20WHERE%20field%20!=%20'Good'
Should be this:
curl -X GET https://x.salesforce.com/services/data/v31.0/query?q=SELECT%20COUNT\(\)%20FROM%20YourObj%20WHERE%20field%20!=%20%27Good%27
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With