• Austen Robinson
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies
How can you show all the data (not just the Id's) in a salesforce object using APEX SQL?

I tried this:
 
// without an ID, simply specify the object to then derive the sobject type
DescribeSObjectResult describeResult = Account.getSObjectType().getDescribe();

List<String> fieldNames = new List<String>( describeResult.fields.getMap().keySet() );

String query =
  ' SELECT ' +
      String.join( fieldNames, ',' ) +
  ' FROM ' +
      describeResult.getName()
;

// return generic list of sobjects or typecast to expected type
List<SObject> records = Database.query( query );

System.debug( records );

but get the error: The query has to start with find or select?

Where exactly does that go?

Getting very frustrated.  In my object I have 3 fields I want to extract.  Name, Account_Owner and Wholesale_Name.  Name and Accout_Owner are strings but Wholesale_Name is a reference.  So I want to return:

Name        Account Holder             Wholesale_name

ABC          John Doe                      ABC Company

 
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?
How can you show all the data (not just the Id's) in a salesforce object using APEX SQL?

I tried this:
 
// without an ID, simply specify the object to then derive the sobject type
DescribeSObjectResult describeResult = Account.getSObjectType().getDescribe();

List<String> fieldNames = new List<String>( describeResult.fields.getMap().keySet() );

String query =
  ' SELECT ' +
      String.join( fieldNames, ',' ) +
  ' FROM ' +
      describeResult.getName()
;

// return generic list of sobjects or typecast to expected type
List<SObject> records = Database.query( query );

System.debug( records );

but get the error: The query has to start with find or select?

Where exactly does that go?

Getting very frustrated.  In my object I have 3 fields I want to extract.  Name, Account_Owner and Wholesale_Name.  Name and Accout_Owner are strings but Wholesale_Name is a reference.  So I want to return:

Name        Account Holder             Wholesale_name

ABC          John Doe                      ABC Company

 
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?