9

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

3 Answers 3

5

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.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
              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

4

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

0

In Schema Builder required fields are marked with red on the left side:

enter image description here


Source: https://www.infallibletechie.com/2021/11/how-to-find-all-required-fields-within.html

You must log in to answer this question.

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