Activity › Forums › Salesforce® Discussions › Is there any way to select all fields of object via soql query in Salesforce?
Tagged: Custom Component, Dynamic SOQL, Object Field, Object Record, Salesforce Customization, Salesforce Objects, Salesforce SOQL, SOQL, SOQL Query
-
Is there any way to select all fields of object via soql query in Salesforce?
Posted by Ankit on January 12, 2018 at 12:48 PMIs there any way to select all fields of object via soql query?
I tried * it doesn’t works.
Parul replied 7 years, 7 months ago 5 Members · 4 Replies -
4 Replies
-
Hi Ankit,
You can use “WORKBENCH” for this. In workbench you have to first login with your salesforce credentials and then go to Queries tab and select SOQL Query. There you have option to select your object and all their fields with filter and sort functionality also.
Hope this will helps you.
- [adinserter block='9']
-
In developer console , go to open -objects- objectname- select the fields using shift button on keyboard – click on Query button present at the bottom of same screen. You can see query form with all fields in query editor of sales force.
-
No equivalent. You need to specify all fields to be retrieved. You can use the APEX describe command to get all fields and build a query string.
public Void GetAllField()
{
String query =”;
String SobjectApiName = ‘Account’;
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();String strFields = ”;
for(String fieldName : fieldMap.keyset() )
{
if(strFields == null || strFields == ”)
{
strFields = fieldName;
}else{
strFields = strFields + ‘ , ‘ + fieldName;
}
}query = ‘select ‘ + strFields + ‘ from ‘ + SobjectApiName + ‘ Limit 10 ‘;
List <Account> accList = Database.query(query);
}
-
Hi
you can use following code to get fields.
SObjectType objectType = Schema.getGlobalDescribe().get(‘objectAPIName’);
Map<String,Schema.SObjectField> mfields = objectType.getDescribe().fields.getMap();mfields map have field names for that particular object which you will mention in objectAPIName.
I hope this help you.
Log In to reply.