Skip to content

Instantly share code, notes, and snippets.

@sechastain
Created November 11, 2014 15:16
Show Gist options
  • Save sechastain/eaa2996a0a91223931d4 to your computer and use it in GitHub Desktop.
Save sechastain/eaa2996a0a91223931d4 to your computer and use it in GitHub Desktop.
Salesforce Apex List Required Fields
SObjectType sot = Your_Custom_Object__c.SObjectType;
Map<String, SObjectField> fields = sot.getDescribe().fields.getMap();
for(String k : fields.keyset()) {
DescribeFieldResult dfr = fields.get(k).getDescribe();
if(!dfr.isNillable()) {
System.debug('REQUIRED FIELD: ' + k);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment