Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
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

0 votes
1 answer
0 votes
1 answer
asked Nov 21, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer

Browse Categories

...