I need to take all mandatory FIELD NAMEs (not FIELD LABEL) so that I can create object. What are the ways to do it outside copying each FIELD NAME from Object Manager?

  • Do you need programmatic access to the required fields? Jun 12, 2020 at 15:51
  • No. I just need to take fields once.
    – NickName43
    Jun 12, 2020 at 17:11

1 Answer 1


Open the Developer Console window and run this snippet:

Map<String, Schema.SObjectField> fieldMap = Product2.sObjectType.getDescribe().fields.getMap();
Set<String> sysNAuditFields = new Set<String> {'Id',
for (Schema.SObjectField f : fieldMap.values()) {
    Schema.DescribeFieldResult fieldDesc = f.getDescribe();
    if(!fieldDesc.isNillable() && !sysNAuditFields.contains(fieldDesc.getName())) {

Change Product2 for the API name of whichever object you need mandatory fields for.

Note: This will give all mandatory fields at an object level, not those that may have been tagged as required on a specific page layout for the object.

Sample log result for this query in my org

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .