Salesforce Field Sets: The Good, The Bad & The Ugly

Salesforce has a feature known as field sets. A field set is a group of fields on an object that is declaratively defined by a user. The field set’s common purpose is to decide which fields to display on a web page for editing on a form or for read only.

Salesforce documentation covers getting started with field sets. We’ll cover the good, the bad, and the ugly of field sets here.

The Good

  • Ease-of-Use. Salesforce makes it easy to use within VisualForce.
  • An object can have multiple field sets that can be used for various purposes.
  • Objects can have as many field sets as needed.
  • Adding or removing a field to be edited or displayed is as easy as adding or removing it from the field set. This allows easier maintenance of the application as requirements change over time.
  • Parent Fields Supported. One can include fields from parent objects. For example, a Contact field set may include fields from the Account.
  • Required Fields. Fields can be marked as required so one must fill them out on a form.

The Bad

  • Only One Level of Parent Fields Supported. In SOQL, up to 5 parent levels are supported. It would be nice to have that level of flexibility with field sets. One workaround is to create one or more formula fields on the given object or parent object to grab the additional information and then use the formula field in the field set.
  • Easy To Break. Its flexibility is also a weakness. It allows one to remove fields that may be always needed in order for functionality to work. One workaround for this is to have a separate list of always required fields that are merged with the field set’s fields to ensure they aren’t removed.

The Ugly

As an architect, I have to know the capabilities as well as the limitations of the technologies available. Here are the limitations as I see them:

  • Read-Only Fields. It’s nice to mark fields as Required. Having the ability to mark a field as read-only would be great so that one can more easily have a mixture of editable and read-only fields on a section of a page. Upvote the Specify a field as readonly in a fieldset idea and hopefully, Salesforce will implement this much needed feature.
  • Can’t Add Attributes. One can’t add additional data attributes to the field sets. For example, I may want to add layout information or custom labels that may differ for the same field across field sets. One way to workaround this is to create your own metadata, associate it to a given field in a field set, and have the application combine the metadata at runtime to do the desired behavior.

What’s the good, the bad, and the ugly of field sets for you?

Happy Coding,


Leave a Reply

Your email address will not be published. Required fields are marked *