Salesforce Cookies #10

Creating a dynamic SOQL which includes all the fields

I have seen this question several times on developer forums and I thought it could be another addition to Salesforce cookies. If you are wondering how can you query all the fields of an object then you can use the following code snippet.

The above code snippet using describe calls to get all the fields and then created a dynamic SOQL query to get all the field values.

This is quite similar to SQL query which uses wildcard characters – SELECT * FROM Table.