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
Krishnan MishraKrishnan Mishra 

Can anyone please explain me getmap() method in apex?

i encountered the following 
Schema.sObjectType.Account.fields.getmap()

Here what is getMap() method? In which class this method is defined, and what does it do? Also if you can give me more details about this method like can this method be over loaded,what is the return type of this etc etc
Raj VakatiRaj Vakati

You can Use the  Schema.SObjectType.Account.fields.getMap() that describe result's getMap method to return a map that represents the relationship between all the field names (keys) and the field tokens (values) for an sObject.


The following example generates a map that can be used to access a field by name:


 
Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.Account.fields.getMap();
 
Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.Account.fields.getMap();
for(String fiedName : fieldMap.keySet()){
    
    Schema.DescribeFieldResult     field = fieldMap.get(fiedName).getDescribe() ;
}

 
Krishnan MishraKrishnan Mishra
Thanks Raj V also if you can tell me where can i find this getMap()? In which class it's definition is provided?