In Apex you can check this by global describe :
Schema.DescribeSObjectResult r = User.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();
//A nillable field can have empty content. A isNillable Boolean non-nillable field must have a value for the object to be //created or saved.
// if F.isNillable() is false then field is mandatory
Boolean isFieldreq = F.isNillable() ;
System.debug ('F = ' + fieldName + ' isnul= ' + isFieldreq);
}
-
This reply was modified 9 years, 10 months ago by
Ravi.