Sub topic 9
Designing the Field Layout
This chapter assumes you can create a custom report type (CRT) with a primary object and a related object, and that you know how lookup and master-detail relationships work. Here you will decide which fields appear in the report builder for that type and how they are grouped.
What the field layout controls
The field layout is the list of fields a user can pick when building a report on your custom report type. It does not change the data. It only changes which columns are offered. After you define the objects and relationships in a CRT, you edit the layout from the report type's detail page with the Edit Layout button.
The layout is organized in sections. Each object in the report type gets one section by default, and the section's label is the object's name. In the Metadata API, each section is a sections element with a masterLabel and a list of columns.
Add, remove, and arrange fields
In the layout editor, you move fields between the Fields Available for Reports list and the section list. Three actions matter most:
- Add fields from related objects. Use Add fields related via lookup to pull in fields from objects reached through a lookup on one of the report type's objects, such as the Account Owner's name on a Contact. Lookup fields can reach up to four levels away from the object.
- Create a new section. Group fields by topic, such as "Billing" and "Support", rather than by object. Users find them faster.
- Rename fields. Double-click a field to change its display label for this report type only. The field's label on the object stays the same.
You can also mark fields as Checked by Default, so they appear as columns in a new report, and as Unchecked by Default for fields that are available but not shown at first. In metadata, this is the checkedByDefault element.
A layout in metadata
This is the layout from the Account with or without Contacts report type. It has one section per object. The table value names the object, and Account.Contacts identifies the contacts reached through the relationship.
<sections>
<columns>
<checkedByDefault>true</checkedByDefault>
<field>Name</field>
<table>Account</table>
</columns>
<masterLabel>Accounts</masterLabel>
</sections>
<sections>
<columns>
<checkedByDefault>true</checkedByDefault>
<field>LastName</field>
<table>Account.Contacts</table>
</columns>
<masterLabel>Contacts</masterLabel>
</sections>Layout choices and their effects
| Choice | Effect on users | Common mistake |
|---|---|---|
| Few fields in the layout | A short, clear field list | Leaving out a field that users need, which forces a layout change later |
| All fields added | Maximum flexibility | A long list that is hard to search |
| Checked by default on key fields | New reports start with useful columns | Checking too many, which makes a wide report |
| Renamed field labels | Clearer names for your audience | Labels that differ from the object, which confuse people who work in several report types |
The layout is not security
Putting a field in the layout does not give users access to its data. Field-level security still applies. If a user cannot see a field, the column is hidden or blank for that user, even if it is in the layout. The next chapters on access cover this in detail.
Exercise
A sales manager wants a new report type to open with Account Name and Contact Last Name already shown as columns, but also wants Industry available as an optional column. How do you set up the layout, and what do you expect to happen to Industry?
Show answer
Add Name from Account and LastName from Contact to the layout and mark them Checked by Default. Add Industry to the layout but leave it unchecked. Industry is then available in the report builder's field list, and the user can add it as a column, but it does not appear in a new report automatically. Users without field-level access to Industry will still not see its values.