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
AAKAlanAAKAlan 

SOQL has apparently lost a field?

Hi,

 

I'm having a wierd query problem with the lead object.

 

Here's my SQL query:

 

$query = "select FirstName, LastName, Address, Company, Phone, Email from lead where Id = '$leadid'";

 

Unfortunately, running this query via the API, I keep getting the following error message:

 

INVALID_FIELD: select FirstName, LastName, Address, Company, Phone, Email from ^ ERROR at Row:1:Column:29 No such column 'Address' on entity 'Lead'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

 

I have checked the lead object over and over again using Setup/Customize/Fields and "Address" appears to be a perfectly valid fieldname. However, when I remove "Address" from the query, it works perfectly.

 

Any idea why the query is rejecting the Address field?

 

Thanks in advance....

 

P.S. Using the Partner WSDL.

Best Answer chosen by Admin (Salesforce Developers) 
SteveBowerSteveBower

Essentially, Salesforce exposes different things with the UI than with the API.  In some cases, this being one of them, they present the underlying data as a concatenated field instead of it's components.

 

For example, on Contact, they present a single field for the Mailing Address.  However under the covers there are several fields like MailingStreet, MailingCity, etc.

 

Similarly, on Contact you only see the combined Name field.  However in the data model there is a FirstName, LastName, etc. fields.

 

 

So, when you're working through the API, use the API documentation on fields:

http://www.salesforce.com/us/developer/docs/api/index.htm

 

Look at Reference -> Standard Objects -> Leads  and you'll see the API fields.

 

Best, Steve.

All Answers

SteveBowerSteveBower

Lead doesn't have an "Address" field.  It does have "Street", "City", "State", "PostalCode", and  "Country" fields. 

 

Use those instead.

 

Best, Steve.

AAKAlanAAKAlan

Thank you, that fixed everything.

 

 

But I still admit to being a bit baffled :-)

When I go into my client's organization, click on Setup/Customize/Leads/Fields I get a field list that doesn't seem to include -any- of those fields and does indeed include a field named "Address".

 

Am I looking in the wrong place or is there somewhere to find a comprehensive list of the fieldnames, particularly for standard objects?

 

Thanks for your help. Thanks for any more guidance you might provide.

 

Alan

SteveBowerSteveBower

Essentially, Salesforce exposes different things with the UI than with the API.  In some cases, this being one of them, they present the underlying data as a concatenated field instead of it's components.

 

For example, on Contact, they present a single field for the Mailing Address.  However under the covers there are several fields like MailingStreet, MailingCity, etc.

 

Similarly, on Contact you only see the combined Name field.  However in the data model there is a FirstName, LastName, etc. fields.

 

 

So, when you're working through the API, use the API documentation on fields:

http://www.salesforce.com/us/developer/docs/api/index.htm

 

Look at Reference -> Standard Objects -> Leads  and you'll see the API fields.

 

Best, Steve.

This was selected as the best answer
AAKAlanAAKAlan

Excellent information! Thank you, Steve!

 

 

Alan