Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
1 view
in Salesforce by (11.9k points)

Is there a way to fetch a list of all fields in a table in Salesforce?  

DESCRIBE myTable

doesn't work, and 

SELECT * FROM myTable

doesn't work.

1 Answer

+1 vote
by (32.1k points)

select * from table_name is used in SQL. But, SOQL doesn’t support anything like that. You’ll need to use the following code for the same:

SObjectType accountType=Schema.getGlobalDescribe().get(‘Account’);

Map<String,Schema.SObjectField>mfields=accountType.getDescribe().fields.getMap();

To learn in-depth about Workflow in Salesforce, sign up for an industry based Salesforce developer certification

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...