Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
DictionaryFField Sets
AdministrationAdvanced

Field Sets

A Field Set is a grouping of object fields that Salesforce admins define once and reference from Visualforce pages, Lightning Web Components, or managed-package code.

§ 01

Definition

A Field Set is a grouping of object fields that Salesforce admins define once and reference from Visualforce pages, Lightning Web Components, or managed-package code. The field set lists which fields to display in the consuming code, in what order, and which are required versus optional. Developers reference the field set by name; the rendered output dynamically pulls the current field list. If an admin adds or removes a field in the field set, every page or component referencing it updates without code changes.

Field Sets are most useful in managed packages and dynamic forms where the customer should be able to customize which fields appear in a developer-built component without editing source code. The classic use case is a Visualforce page (Edit My Profile) that uses a field set named PersonalInfo; the developer ships the page once, and customers add their custom fields to the PersonalInfo field set to extend the form. Field Sets are configured per-object under Object Manager. They are a niche feature that solves a specific problem well but does not replace standard page layouts or dynamic forms for general-purpose record layouts.

§ 02

How Field Sets let admins customize field visibility in code without editing the code

The configuration: where Field Sets live

Field Sets live under Object Manager, on each object''s configuration. Pick an object, click Field Sets, click New. Configure name (PersonalInfo, ContactCard), description, and the available fields in the side panel. Drag fields into the field set; reorder within the field set; mark fields as Required if the consuming code should treat them as mandatory. Save. The field set is now available to any Visualforce page or LWC referencing it by name.

Visualforce usage

The classic consumer. Visualforce code uses apex:repeat over $ObjectType.Object.FieldSets.MyFieldSet to render each field dynamically. The page renders the current field list at runtime. Admin adds a field to the field set, the page picks it up on next render. The pattern made Visualforce pages adaptable without redeploying code; it was a meaningful capability when Visualforce was the dominant UI tier and admins could not edit pages directly.

Lightning Web Component usage

LWC supports Field Sets via the lightning-record-form base component with the field-set attribute. The component fetches the field set definition via Salesforce schema services and renders the fields. The LWC pattern is more limited than Visualforce; lightning-record-edit-form and lightning-record-view-form do not natively support field sets without custom Apex helper code. For most modern LWC work, dynamic field rendering uses other patterns (Apex @AuraEnabled methods returning field lists, getRecord with fields parameter).

Managed packages and the field-set extension pattern

Managed packages use Field Sets as the canonical customization extension point. The package developer builds a page or component referencing a field set; customers add custom fields to the field set after install. The customer-side field additions persist through package upgrades because the field set is customer-org-local while the consuming code is package-namespaced. Without field sets, managed packages would have to ship every reasonable field permutation hard-coded; with field sets, customers extend the package without editing it.

Field Sets versus Dynamic Forms

Two related-but-different features. Field Sets are a developer construct: code references a named group, admin manages which fields are in the group. Dynamic Forms are a Lightning record page feature: admins drag fields onto the record page directly without involving code. Dynamic Forms cover the common-case "let me put different fields on different record-type pages" need; Field Sets cover the rarer case "let me ship code that customers can extend without rebuilding."

Limits and considerations

Each object has a cap on the number of Field Sets it can hold (around 50, varies by edition). Each field set has a cap on the number of fields it can reference (around 100). Field-level security applies on top of field sets; a user without read access to a field sees it as blank even if it is in the field set. Field Sets reference fields by API name; renaming or deleting a field that is in a field set breaks the field set silently until manually cleaned up.

When to use Field Sets in modern Salesforce

Three legitimate use cases. ISV-distributed managed packages that need customer-extensible fields. Custom Visualforce pages (still in some legacy orgs) that need admin-configurable field lists. Specialized LWC components where Dynamic Forms cannot cover the use case (programmatic rendering with custom logic per field). For standard Lightning record pages, default to Dynamic Forms; for managed packages, Field Sets remain the cleanest extension pattern.

§ 03

Creating and using Field Sets

Setup is two phases: define the field set in Object Manager, then reference it from Visualforce or LWC code. Most usage involves both an admin creating the field set and a developer consuming it.

  1. Open Object Manager

    Setup, Object Manager, pick the target object. Click Field Sets in the left sidebar. The list shows any existing Field Sets for the object.

  2. Create the Field Set

    Click New. Enter Field Set Label, API Name, and Description. The description is critical; future admins need to know what consuming code expects from this field set.

  3. Add fields to the Field Set

    Drag fields from the In the Field Set panel onto the canvas. Reorder by drag. Mark fields as Required if the consuming code should treat them as mandatory at validation. Save.

  4. Reference from Visualforce or LWC

    Visualforce: <apex:repeat value="{!$ObjectType.MyObject.FieldSets.MyFieldSet}" var="f"><apex:inputField value="{!record[f]}"/></apex:repeat>. LWC: pass the field set name to a component that fetches and renders the field list via @AuraEnabled Apex or lightning-record-form.

  5. Iterate on the field set, not the code

    Once the code references the field set, admins extend or shrink the field list without redeploying. Document the field-set name in the consuming code so future admins know what page or component depends on it.

Key options
Required flagremember

Per-field setting inside the field set. Marks the field as required at validation in consuming code. The flag does not change object-level required-field metadata.

Field orderremember

Drag to reorder. Consuming code renders fields in the field-set order. Reordering changes the rendered output without code changes.

Available fieldsremember

Any field on the object can be added to the field set, including standard fields, custom fields, and formula fields. Cannot add fields from related objects without a custom Apex bridge.

Consumer typesremember

Visualforce (native support), Lightning Web Components (via Apex helper or lightning-record-form), managed packages (extension pattern), Apex (Schema.FieldSet introspection).

Gotchas
  • Field-level security applies on top of field sets. A user without read access sees the field as blank, not as removed.
  • Renaming or deleting a field that is in a field set silently breaks the field set. Audit field sets after schema changes.
  • LWC does not natively support field sets in lightning-record-edit-form. Use Apex helper or lightning-record-form for LWC.
  • Field Sets cap at around 50 per object and 100 fields per set. Hit these caps and the platform rejects the addition.
  • For standard Lightning record pages, Dynamic Forms is the better tool. Field Sets are for code-driven dynamic rendering, not for record layouts.
§

Trust & references

Sources

Cross-checked against the following references.

Official documentation

Straight from the source - Salesforce's reference material on Field Sets.

Keep learning

Hands-on resources to go deeper on Field Sets.

Was this entry helpful?
Help us write better definitions. Quick reactions or detailed edit suggestions.

About the Author

Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.

§

Test your knowledge

Q1. What is a Field Set?

Q2. Why use Field Sets?

Q3. What's the modern Lightning alternative for similar dynamic behavior?

§

Discussion

Loading…

Loading discussion…