String objType='Contact'; Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); Schema.SObjectType leadSchema = schemaMap.get(objType); Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap(); List<String> shagni = new List<String>(); for (String fieldName: fieldMap.keySet()) { Schema.DisplayType fielddataType = fieldMap.get(fieldName).getDescribe().getType(); System.debug(fielddataType); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter