Field Sets

As discussed in Chapter 2Leveraging Platform Features, utilization of the Field Sets platform feature is key to ensuring that your application is strongly aligned with the customization capabilities that your application's users expect. However, you might be wondering what this has to do with querying data. Well, even though most of our discussions around this feature will focus on the use of it in a UI context, the additional Custom Fields added to the subscriber org still need to be queried in order for them to be displayed; otherwise, an exception will occur just the same as if you had failed to query a packaged field.

To use this feature, you need to override the getSObjectFieldSetList method and construct the Selector with the includeFieldSetFields parameter. The default constructor sets this parameter to false so that, in general, the Field Sets fields are not included. The following example assumes a field set on the Race object called SeasonOverview (included in the source code of this chapter):

The following code illustrates the configuration of this feature (note that the logic in the base class also ensures that if the subscriber adds your own packaged fields to the Field Set, such fields are only added to the SOQL statement field list once):

public RacesSelector() { 
  super(); 
} 
 
public RacesSelector(Boolean includeFieldSetFields) { 
  super(includeFieldSetFields); 
} 
 
public override List<Schema.FieldSet>getSObjectFieldSetList() { 
  return new List<Schema.FieldSet> 
     { SObjectType.Race__c.FieldSets.SeasonOverview }; 
}

Field Sets are a key feature for your customers to enable extensibility within your logic and user interfaces. This allows them to have your application understand Custom Fields they add to objects in order to extend your application's data storage needs for their own purposes. In the next section, we will take a look at another key platform feature that extends the data model in order to support Multi-Currency use cases that some of your customers may have.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.81.206