function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AnjaanAnjaan 

How can i get the field names of SObject

Hello All,
 
I want to get field names of an SObject like Contact or Account. How can i get them. Currently i am trying to get them via

Map<String, Schema.SObjectField> m = Schema.SObjectType.Contact.fields.getMap();

I can get the string by m.getKeySet but how can i get the field names using Schema.SObjectField


Code:
public List<String> getDBFields(){

Map<String, Schema.SObjectField> m = Schema.SObjectType.Contact.fields.getMap();         

List<SObjectField> temp = m.values();

// Now i have to get the Label of each field

}

 Anyone help please


hisrinuhisrinu
        Map<String, Schema.SObjectField> m = Schema.SObjectType.Contact.fields.getMap();
        List<Schema.SObjectField> fTokens = m.values() ;
        for( Integer i = 0 ; i < fTokens.size() ; i++ ){
        Schema.DescribeFieldResult f = fTokens.get(i).getDescribe() ;

Message Edited by hisrinu on 01-01-2009 10:13 PM