+ Start a Discussion
Austen RobinsonAusten Robinson 

new to salesforce struggling with reference type fields

I'm trying to do a query to return a field with the type reference.  I am assuming that it means the field resides in another object table?

How do you return the value of a reference field in a simple SQL statement?
sfdcfoxsfdcfox
I'm trying to do a query to return a field with the type reference.  I am assuming that it means the field resides in another object table?

Yes, references refer to another record. It may be another object (like Contact Account), or it may be the same object (like Account Parent), or it may refer to multiple objects (like Task Who).

How do you return the value of a reference field in a simple SQL statement?

If the field refers only to a single object, you can't determine the type from a query. There's describe calls for that purpose (e.g. DescribeSObject and DescribeField). However, fields that do, or can, refer to multiple objects, are described as a Name relationship. Those fields have a Type field that describes what the field is related to. For example:
SELECT Who.Type FROM Task
Returns either Contact or Lead, depending on the record in the Related To field. Generally, you'll have to know when you need to call describes versus when you can use the Type field.
Austen RobinsonAusten Robinson
I read all this several times but still having trouble wrapping my head around it.

An example of this:      SELECT Who.Type FROM Task

Would certainly help

My scenario:

Salesforce object = ACNA
Field I want to get the string name (not the id) is Wholesale_Name__c  which is type reference

so what I am after is :

Joes Garage
Sams Supplies
etc.