FieldSet defines a grouping of fields on a specific Salesforce object. Its primary documented use is to control which fields appear on Visualforce pages that read the field set dynamically. For a page delivered in a managed package, administrators can add, remove, or reorder members to change the presentation without modifying page code.
A field set is configuration for its consumers, not a page, a field definition, or an executable process. Its effect depends on the pages and application code that use it. Apex can also use membership to choose fields for queries or data processing, so a membership change is not necessarily limited to presentation.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The metadata identity of the field set. It must be specified for creation, update, and deletion and cannot be null. It is distinct from label. |
availableFields |
A collection of FieldSetItem entries describing the possible fields available for the field set. Availability alone does not mean a field is displayed. |
displayedFields |
A collection of FieldSetItem entries identifying the fields presented by the consuming Visualforce page. Their sequence determines their order of appearance. |
field |
Required within each member entry in either collection. Identifies a field on a standard or custom object; it references the field definition rather than defining a new field. |
description |
Required developer-provided text explaining the purpose of the field set. |
label |
The required label for the field set. Do not substitute this display text for its metadata identity. |
isFieldManaged |
Read-only boolean on a member entry. Records package-provenance information about whether the field was added through a managed or unmanaged package. |
isRequired |
Read-only boolean on a member entry. Documented as indicating whether the field is universally required: true or false. It is not a switch for changing the underlying field's requiredness. |
Behavior and Constraints
Available and displayed membership serve different purposes. A field listed under availableFields is a possible choice, not necessarily a field shown on the page. The order of displayedFields controls presentation order; it does not establish an execution order for application logic.
Both collections contain FieldSetItem entries. Changing an entry changes the field set's membership or member information, not the referenced field definition. In particular, the read-only isRequired value does not make the underlying field required or optional.
The consumer determines the impact. A referencing Visualforce page can present different fields after a field-set change even when the page itself is unchanged. Community implementations also use members to select mass-edit fields and construct aggregate SOQL queries. SOQL is Salesforce's query language. In those implementations, changing membership changes application processing as well as the user interface.
Apex can discover field sets by name through runtime describe information, which exposes object configuration to code. One reported implementation resolves an object through Schema.getGlobalDescribe(), reads its describe result's fieldSets.getMap(), selects a field set by name, and calls getFields(). The resulting Schema.FieldSetMember objects expose field paths through getFieldPath(). These runtime objects are distinct from Metadata API FieldSetItem entries.
Do not assume that related-object field selection supports every relationship path that SOQL supports. A community report updated in 2019 describes selection from the base object and one parent level, but not deeper traversal. This is a reported field-set limitation, not a general SOQL relationship limit.
Deployment and Retrieval
FieldSet is represented by fieldSets entries within a CustomObject definition. Each entry carries the field set's own fullName, membership collections, description, and label. The object is the container; the field set is the object-scoped component.
The type supports the wildcard character * in the package.xml manifest used for deployment and retrieval. For creation, update, or deletion, identify the field set by fullName in the correct object scope, not by its label.
Match the destination object and field-set name when moving consumers. A reported Apex compilation failure occurred because sample code referenced a field set that had not been created on the specified object. A complaint that a name is not a field set of an object can therefore indicate a missing or mismatched definition rather than a missing enablement setting.
Member entries reference existing fields; they do not contain the fields' definitions. Removing a member from a field set is different from deleting the underlying field. Before removing a field set or changing its membership, account for its Visualforce consumers, translations, rule references, and Apex code that resolves it by name. A page-reference search alone may not expose that name-driven Apex usage.
Field-set-dependent tests can also depend on deployed metadata rather than ordinary test records. A community discussion updated in 2021 reports that tests cannot directly create field sets or construct Schema.FieldSetMember instances. The described approaches use an existing field set or an abstraction around runtime members that tests can replace.
Relationships
The main dependency chain is page to field set to field definition. CustomObject contains field sets through fieldSets. The element references below describe possible connections; they do not establish that a particular component uses a particular field set.
References
-
CustomField:fieldwithinavailableFieldsanddisplayedFields.
Referenced By
-
ApexComponent: references embedded infiledata. -
ApexPage: references embedded infiledata. -
CustomObjectTranslation:namein field-set translation entries. -
FieldRestrictionRule:classification.
A FieldRestrictionRule reference is an incoming rule dependency. The association alone does not establish the rule's access effects or show that a user can access the member fields.
Separately from these element references, Apex can select a field set using an object name and field-set name at runtime. This name-based usage matters when assessing the impact of changing or removing a definition.
Reported Issues
- A membership change can change processing, not just displayed fields. A 2017 community implementation used field sets to choose fields for a custom mass-edit tool and to build aggregate SOQL queries. The effect depends on how the consuming Apex interprets the members. Mass-edit and aggregate-query examples.
-
Page-reference checks alone may miss a consumer. A 2012 community implementation selected both the object and field set by name at runtime using
Schema.getGlobalDescribe(),fieldSets.getMap(), andgetFields(), then read member paths withgetFieldPath(). Dynamic Apex lookup example. - A missing editor choice does not necessarily mean the field is absent. In a Field Service managed-package discussion, a field was available in one field set but not another. A 2018 response attributed the difference to package authors needing to make individual packaged fields eligible for addition. Treat package-author eligibility as a reported constraint to investigate. Managed-package field eligibility report.
- A deeper parent field may not be selectable even when its relationship path is valid in SOQL. A community report updated in 2019 describes field sets as supporting fields on the base object and one parent level, but not deeper traversal. The report concerns field-set selection, not SOQL's general capabilities. Related-object selection report.
- Apex compilation can fail when the referenced object-scoped field set is missing. In a 2013 report, sample code referenced a field set that had not been created on the specified object. The response directed the developer to create the definition and match its name to the code reference. Missing field-set compilation case.
-
Tests can require deployed configuration that test records cannot replace. A discussion updated in 2021 reports that tests cannot directly create a field set or construct
Schema.FieldSetMemberinstances. It describes using existing metadata or wrapping runtime members behind an abstraction for testing, which matters when packaging or moving dependent Apex tests. Testing field-set-dependent code.
Common Questions
How do I deploy or retrieve a Salesforce field set?
FieldSet appears as a fieldSets entry within a CustomObject definition. Its fullName identifies it in the object's scope. The type supports * in the package.xml manifest.
Why is a field available in the field set but not displayed?
availableFields describes possible choices. displayedFields identifies the fields presented by the consuming Visualforce page and their order. The consuming page or application code determines the field set's actual effect.
Why does Apex say my field-set name is not a field set of the object?
A reported cause is a missing definition on the referenced object. Check that the destination contains the field set on that exact object and that the code uses the matching field-set name, not its label.
Why can't I add a field to a managed-package field set?
A community report attributes some missing choices to package-author eligibility settings for individual packaged fields. A field being available in another field set does not prove that it is eligible for the one you are editing.
Can I create a field set inside an Apex test?
Community reports state that tests cannot directly create field sets or construct Schema.FieldSetMember instances. The described alternatives are to use deployed field-set metadata or an abstraction around runtime members that can be replaced during testing.