Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sunil02kumar/0e3c300bf0639f04cbb824b9f820535f to your computer and use it in GitHub Desktop.
Save Sunil02kumar/0e3c300bf0639f04cbb824b9f820535f to your computer and use it in GitHub Desktop.
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
for(String ss1: schemaMap.keyset()){
if(ss1.equalsignorecase('Contact')){
Schema.SObjectType objToken=schemaMap.get(ss1);
//find details about sobject
Schema.DescribeSObjectResult objDescribe=objToken.getdescribe();
system.debug('*********sobjectAPINamel:'+objDescribe.getName());
system.debug('*********sobjectlabel:'+objDescribe.getlabel());
system.debug('*********sobjectPrefix:'+objDescribe.getKeyPrefix());
system.debug('*********IsCustom sobject:'+objDescribe.IsCustom());
//finding all fields of sobjects
Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
for(String ss:Fieldmap.keyset()){
Schema.DescribeFieldResult fd=fieldMap.get(ss).getDescribe();
system.debug('*********fieldAPINamel:'+fd.getName());
system.debug('*********fieldlabel:'+fd.getlabel());
system.debug('*********fieldtype:'+fd.gettype());
system.debug('*********isNillable:'+fd.isNillable());
//check if data type is picklist then find out picklist options
if(String.valueof(fd.getType()).equalsignorecase('Picklist')){
List<Schema.PicklistEntry> Pp = fd.getPicklistValues();
for(Schema.PicklistEntry p:Pp){
system.debug('****picklist option label'+P.getLabel());
system.debug('****picklist option value'+P.getvalue());
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment