0

Is it possible to figure out which fields are required from Setup?

I mean, I can of course go and look at each field settings and check the required checkbox, but very often I need to look at a few objects and get to know their required fields. So, going over every field in those objects takes some time, while it would be a lot faster to see all required fields at once.

2

As far as I know of, there's no way from UI to get that information.

But you can retrieve this information if you use Metadata API. You can use the attribute required on the CustomField metadata for an object which provides you the detail you need here.

The easiest way will be to pull the components in your local repository and then just look through the generated XML which will consist of this information.

1

Jayant's answer is the better approach for an organization-wide review, and I wanted to add another approach that is limited but quicker for single-object checks.

You can run Tooling API queries from the Developer Console if you tick the "Use Tooling API" box. You can run queries like this one to get back required field lists for one object at a time:

SELECT QualifiedApiName 
FROM FieldDefinition 
WHERE EntityDefinition.QualifiedAPIName = 'Account' 
      AND IsNillable = false 
      AND DataType NOT IN ('Checkbox', 'Formula (Checkbox)')
      AND PublisherId != 'System'

This gets to the fields that are required by using whether they're nillable as a proxy - we just drop Checkboxes, because they're never null and can't be database-level required. Note that system fields like SystemModStamp and Id are included, because they cannot be set to null, unless we include the PublisherId != 'System' clause.

Note, of course, that neither the Tooling nor Metadata API approaches at the field level will tell you whether a field is required at the page layout level or by a validation rule - this is only database-level requirement.

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.