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
hchenghcheng 

Query to autonumber field returns no results using Web Services API

Hi,

 

I'm using JAVA to call the salesforce Web service API and am having a problem querying by the autonumber field.  When I query against the name (autonumber) field, no results are returned - SELECT ID, Status__c, Name from MYOBJECT__C where Name='123456').

 

Queries against other fields (eg: picklist - where Status__c='New') or against all records (from MYOBJECT__C - no where clause) return the correct results. 

 

Is there a specific syntax for querying autonumber fields?  I thought the syntax was correct, but should I be using - WHERE NAME LIKE '%123456%'?  I'm sure I missing something obvious.

 

Appreciate any ideas.


Thx

 

How

 

jhurstjhurst

Autonumber fields shoul dbehave in the same way that text fields do.  So in your example, both queries should work:

 

SELECT ID, Status__c, Name from MYOBJECT__C where Name='123456'

SELECT ID, Status__c, Name from MYOBJECT__C where Name like '%123456%'

 

The only reason why they may not work is if the value you are searching for ('123456') does not exist, or if there is some issue with the indexing of the name field.   Indexing would be solved by time, and should be relatively quick, but may take a little while if you created many records through the API.

 

My suggestion would be to log a case with salesforce.com support if this is still happening.  Once you have done so, let me know the case number qand I can get it assigned to one of our reps.

 

Thanks

Jay