4

How can I find and see the required fields of an object in salesforce? For example I want to find all the required standard or custom fields of the Opportunity object in NPSP.

I am not looking for code. Just instructions

4

Easiest way(s) other than clicking on each field:

Declarative:

Create a new blank page layout. Any fields you cannot remove will be required.

Or via Code

In the Dev console execute:

Opportunity o = new Opportunity(Name='test',AccountID = PUTANACCOUNTIDHERE, StageName = 'Test');
Insert o;

And see what it tells you is missing. You may have to do it several times, each time completing one of the required fields...

or using code found in this answer:

https://developer.salesforce.com/forums/?id=906F00000008qYdIAI

Schema.DescribeSObjectResult r = Opportunity.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
              if(F.isNillable())
                  system.debug(fieldName + ' - is Required');
           }

Others will have additional options like using MaventsMate or Eclipse to export the Object Metadata then you can do a search for Require = true

1

Bit of a slog this point and click method, but try these steps:

  1. Switch to Salesforce Classic mode
  2. Navigate to Setup
  3. Look for Field Accessibility under Security Controls
  4. Pick an Object > View by Profile > Pick a Profile
  5. Required Fields display in Red

Required Fields Point and Click

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.