+ Start a Discussion
sundar s 24sundar s 24 

how to get api name of all fields in an object using developer console

how to get api name of all fields in an object using developer console
Suraj Tripathi 47Suraj Tripathi 47

To get all the field of the object please use the below code in the query editor:-
SELECT  QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Account'

To get all object in salesforce:-
for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
    Schema.DescribeSObjectResult objResult = o.getDescribe();
   // system.debug( 'Sobject: ' + objResult );
    system.debug( 'Sobject API Name: ' + objResult.getName() );
    system.debug( 'Sobject Label Name: ' + objResult.getLabel() );   

Please mark it as Best Answer if it helps you.

Thanks & Regards
Suraj Tripathi
Hii Sundar
Try Below Code
public with sharing class dynamicObjectList { 
 public static List<FieldDefinition> getfields(string objectname){
        string query = 'select DeveloperName,QualifiedApiName from FieldDefinition where EntityDefinition.QualifiedApiName = :objectname ORDER BY DeveloperName ASC';
        list<FieldDefinition> lstObject = Database.query(query);
        system.debug('lstObject==> '+lstObject);
        for(Integer i=0;i<lstObject.Size();i++){
            system.debug('lstObject==> '+lstObject[i].QualifiedApiName);
        return lstObject;
Please Mark It As Best Answer If It Helps
Thank You!
sundar s 24sundar s 24
when i tried to get fields from workflowemailalert i got below fields what is the name of Recipient field here my idea if want to get email recipinet for a user from email alert