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
Amar123Amar123 

Apex code to get schema(Fields) of contact object.

Best Answer chosen by Amar123
Prateek Prasoon 25Prateek Prasoon 25
String SobjectApiName = 'Contact'; Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap(); for(String fieldName : fieldMap.keyset() ) { system.debug('fieldName->>'+fieldName); // This will give you the api name of the field name. }