+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 (31.6k 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();

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


Categories

...