It is very common that we need to check the field properties of a salesforce object. If there are a large number of fields, it is very time consuming to click on each field one at a time from salesforce user interface. The following Apex code demonstrates how to print the nullable properties of all the fields in the Account object. You can change it to other objects or print different field properties.
Schema.DescribeSObjectResult r = Account.sObjectType.getDescribe();
Map<String,Schema.SObjectField> M = r.fields.getMap();
for(String fieldName : M.keySet()){
Schema.SObjectField field = M.get(fieldName);
Schema.DescribeFieldResult F = field.getDescribe();
Boolean isFieldreq = F.isNillable() ;
System.debug (fieldName + ‘ is null: ‘ + isFieldreq);
}
Reblogged this on Sutoprise Avenue, A SutoCom Source.