Pages

Salesforce SOQL

Salesforce uses a modified sql language called Salesforce Object Query Language (SOQL). Occasionally I wrestle with the syntax. Here's a few hints for the simple stuff:

Poorly formatted fields

Numeric labels placed in number type field and has comma in places that don't make sense for a number.

First attempt: enclose in single quotes, like '12,000,000,99'

INVALID_FIELD:
SELECT id, name FROM Account WHERE rep_id = '12
^
ERROR at Row:1:Column:36
value of filter criterion for field 'rep_id' must be of type double and should not be enclosed in quotes.

Second try: without quotes

unexpected token: ','

Third idea: export records and look at the data. The commas are only on the page layout when displayed, not in the table record. No commas! yeah.

SELECT id, name FROM Account WHERE rep_id = 1200000000099
MALFORMED_QUERY: 
WHERE OASP_FSC__Orion_Rep_ID__c = 66200000000011
                                  ^
ERROR at Row:1:Column:64
For input string: "66200000000011"

Fourth idea: add a zero to make it a double?

SELECT id, name FROM Account WHERE rep_id = 1200000000099.0

It worked!!!!