Difference between revisions of "Enumerated Fields"
imported>Aeric |
imported>Aeric |
||
Line 62: | Line 62: | ||
==Working with Picklists== | ==Working with Picklists== | ||
{{:Working with Picklists}} | {{:Working with Picklists}} | ||
==Working with Global Picklists== | ==Working with Global Picklists== | ||
Line 78: | Line 77: | ||
==Working with Dependent Picklists== | ==Working with Dependent Picklists== | ||
When the possible choices need to depend on selections made in other fields, use a [[Dependent Picklist]]. | When the possible choices need to depend on selections made in other fields, use a [[Dependent Picklist]]. | ||
==Working with a Multi Select Picklist== | |||
{{:Multi Select Picklist}} | |||
==Using Enumerated Fields with Other Platform Elements== | ==Using Enumerated Fields with Other Platform Elements== |
Revision as of 00:29, 24 January 2012
Enumerated fields can provide a powerful visual impact by displaying a graphic image or color-coded label in place of field values.
About Enumerated Fields
Enumerated fields have an associated numeric value, which can be used to group, sort or filter data in Views and Reports. (In Reports, enumerated fields can appear as color-coded labels, only.)
Enumerated fields include these elements:
- Display Label
- Can be either an alphanumeric string or an image, or both.
- Alphanumeric string, with optional color coding for text and background color
- Image, optional, selected from the Documents object
- Not used to group, sort, or filter records
- Item Value
- Stored as part of the record.
- Used to group, sort, or filter records.
- A number that can be used to define the display order.
Enumerated Types
These Field Display Types are enumerated:
Displaying Enumerated Fields
Enumerated Fields in Views can provide users with visual indicators of a data metrics. In this example, a movie library View is enhanced with the addition of stars to rank the movies by preference. Although the ranking (Picklist Value) is not displayed, it is used to sort the list.
- The ranking (with 1-4 stars) is created by adding a series of images and values to eligible Field Display Types:
Because the Picklist Value is stored in the database, it can be used in these areas of the platform: - Sort order in Views and Reports
- Filters in Views and Reports
- Color coding criteria in Views and Reports
- Grouping criteria in Reports
Learn more: Using Enumerated Picklists with Other Platform Elements
Common Operations
Specify a Default Value
Default Value for an Enumerated Field
Manage and Reorder Values
The Enumerated Values section of the field-definition page, lets you specify the picklist values and the order in which they appear.
To specify which values appear:
- Click [Manage Values]
- Click the box under the Trash can to remove an item.
- Click [Add More Rows] to add additional items
- Click [Save] when done
- Settings
-
- Display Label - The label to display in the list.
- Value - The actual value that is stored in a record (or returned to a program) when the item is chosen from the list. When the field is used to group, sort, or filter records, it is the value of the field that determines the outcome.
Note: Alphanumeric Characters are allowed in labels and values, including special characters (+ / ' - _) and spaces.
Reorder Values
In the Enumerated Values section of the field-definition page, click [Reorder Values] to change the order in which the values appear:
Working with Checkboxes and Radio Buttons
Working with Checkboxes and Radio Buttons is almost identical to the process for Working with Picklists, described next. The only real difference is in the way that values are displayed, and the number of selections a user can make.
Working with Picklists
A Picklist is a field that can contain a list of values. It appears as a dropdown list when displayed.
Create a Picklist
- Click > Customization > Objects > {object} > Fields
- Click [New Field]
- Provide the information in the sections below.
- Click [Save]
The field is added, and the field-definition is shown.
Basic Information
- Specify the basic characteristics of the field:
- Label - The text that appears as the field name
- Display Type - Picklist
- Picklist Values - For a simple Picklist that returns the same values it displays, with no special colors, images, or groups for the display values, you can simply enter the values, as shown here:
- Otherwise, wait until the Picklist has been created, then Manage and Reorder Values.
- Maximum Storage Length - The String length of the longest value in the list.
- Use First Value as Default - Otherwise, the field is initially empty.
- Sort List Alphabetically - Otherwise, you manually arrange the order.
- Skip Value Validation - When checked there is no validation of the Enumerated Values. By default, this option is unchecked.
- Always Required - A selection must be made when adding or updating a record.
- Field Name - Automatically created by the system (but you can change it here)
Display Attributes
- Determine where the field is displayed in the default form, and whether or not the field is required when adding or updating a record.
Default Value
In general, the default value you specify will be a simple String. For example: 'rush'. But it is also possible to select functions and specify arguments, creating a formula expression that returns the default value.
- Considerations
-
- The default value must resolve to the value of an entry in the list of enumerated items (not a label).
- If the value resolves to a string which is not in the list of the enumerated items, it is as though no default were specified. Nothing is pre-selected in the Enumerated Field.
- Field Visibility determines which roles can see or edit the field.
Description Information
- Include a description of the field and its use. This information is only visible to users with rights to customize this field.
Working with Global Picklists
Create a Global Picklist
- Click Designer > Global Resources > Global Picklists
- Click the [New Global Picklist] button and enter the following information:
- Name - The field label that will be displayed
- Show First Value as Default - Checkbox
- Sort List Alphabetically - Checkbox
- Click [Save].
You can now proceed to Manage and Reorder the Values.
Locked Package Options
When a Global Picklist is included in a published Package, these options determine what the package installer is allowed to do with the Global Picklist.
Working with Dependent Picklists
When the possible choices need to depend on selections made in other fields, use a Dependent Picklist.
Working with a Multi Select Picklist
Multi Select Picklists provide options in a field to make multiple selections from a list of values in a Global Picklist.
In the global picklist, although the labels for the enumerated values may contain commas, the enumerated values may not contain commas.
For Multi Select Picklist fields where the labels include commas, vertical orientation is the better choice
- Considerations
-
- The value stored in the database is a comma-separated list of labels, one for each selection. So:
- If you change the order of the values, new values may be stored differently than old ones.
- To avoid a Data Truncation Error at runtime, make sure the field is large enough to contain all possible selections.
- Calculate the size as the sum of the entry lengths, plus N-1 for the commas between them, where N is the number of entries.
- Use an expression like this one to mark a single box in a Rule action:
- IF( ISNULL(field), 'checkboxLabel', field+', checkboxLabel')
- If the field is empty, the label is assigned to it. If the field has a value, the checkbox label is appended to it.
- The checkbox label is case-sensitive, and must match the configured value exactly.
- Spaces are allowed between items in the value-list (but be sure to size the field appropriately.)
- IF( ISNULL(field), 'checkboxLabel', field+', checkboxLabel')
- To uncheck a box in a rule, you need one of two expressions:
- REPLACE(field, ', checkboxlabel', '') - for multiple selections, or
- REPLACE(field, 'checkboxLabel', '') - for a single selection
- The expressions then need to be placed inside of a nested IF statement to see if either one applies:
- IF (CONTAINS(field, ', checkboxLabel'), -first replacement-,
- IF (CONTAINS(field, 'checkboxLabel'), -second replacement-, field) )
- This expression does the appropriate substitutions of the label is present. Otherwise, it returns the original field.
- IF (CONTAINS(field, 'checkboxLabel'), -second replacement-, field) )
- IF (CONTAINS(field, ', checkboxLabel'), -first replacement-,
Using Enumerated Fields with Other Platform Elements
Because Picklist Values can contain alphanumeric characters, additional functionality becomes available, as listed here:
- Sort order
- Use the Picklist value in Views and Reports to define sort order
- Grouping
- Use the Picklist value to Group records in Views and Reports
- Display in Views
- The Display Labels are shown when displaying a record and in Views. Based on the options selected, the image and the text colors are shown.
- Color coding in Views
- Criteria can be specified using Display Labels or Picklist values; The first match is done using the display label, followed by the Picklist value
- Searches/Filters in Views
- Criteria can be specified using display labels or Picklist values; The first match is done using the display label, followed by the Picklist Value
- Global Search
- Global search can use the Picklist values
- Display in Reports
- The Display Labels are shown (no images or color coding are displayed)
- Reports must not use the Group option
- REST or JAVA API
- The Picklist values are returned (not the display label)
- Conditional Layouts
- Layout rules can use the Picklist values