Intro

The smart field creates different user input controls and their read-only equivalents based on an OData (Open Data Protocol) service and its annotations. It comes with additional built-in features, such as autocomplete and suggestions, value help dialog, recently used and recommended values, validation, and message handling.

information
The smart field is only available for OData version 2.

When to Use

Use the smart field if:

Do not use the smart field if:

Components

The smart field consists of a basic UI element and an optional label. The following UI elements are available:

For details, see the corresponding guideline topics.

User Input Control

The smart field chooses the control automatically based on the data type (Edm type) and annotations of the OData service and additional properties. The following controls are used:

<div> <div></div> <div>Read-Only</div> <div>Edit</div> <div>Edm Types / Annotations / Properties</div> <div>Comment</div> </div> <div> <div>Single-line text</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Finput-field%2F">Input field</a></div> <div> <p>Edm.String</p> <p>Configuration: controlType, value: input</p> </div> <div></div> </div> <div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fcombo-box%2F">Combo box</a></div> <div> <p>Edm.String</p> <p>Configuration: controlType, value: dropDownList</p> </div> <div></div> </div> <div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fselect%2F">Select</a></div> <div> <p>Edm.String</p> <p>Configuration: controlType, value: selection</p> </div> <div></div> </div> <div> <div>Multi-line text</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext-area%2F">Text area</a></div> <div> <p>Edm.String</p> <p>MultiLineText</p> </div> <div></div> </div> <div> <div>Decimal numbers</div> <div> <p><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></p> <p><a href="https%3A%2F%2Fwww.sap.com%2Finternal%2Ffiori-design-web%2Fv1-88%2Fobject-number%2F">Object number</a></p> </div> <div>One or two <a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Finput-field%2F">input fields</a><br>(for number and unit)</div> <div>Edm.Int16, Edm.Int32, Edm.Int64,<br>Edm.SByte, Edm.Byte,<br>Edm.Single, Edm.Float, Edm.Double,<br>Edm.Decimal<br>Precision, Scale</div> <div></div> </div> <div> <div>Status information</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fobject-display-elements%2F%23object-status">Object status</a></div> <div></div> <div> <p>Edm.String</p> <p>criticality, criticalityRepresentationType</p> </div> <div></div> </div> <div> <div>Text and ID</div> <div> <p><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></p> <p><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fobject-display-elements%2F%23object-identifier">Object identifier</a></p> <p><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fobject-display-elements%2F">Object status</a></p> </div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Finput-field%2F">Input field</a></div> <div> <p>TextArrangement</p> <p>controlProposal</p> <p>displayBehavior</p> <p>textInEditModeSource, sap:text,<br>fetchValueListReadOnly</p> </div> <div> <p>The following patterns can be selected via displayBehavior:</p> <ul> <li>Text (ID)</li> <li>ID (Text)</li> <li>Text</li> <li>ID</li> </ul> </div> </div> <div> <div>Links<br>(with/without quick view)</div> <div> <p><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Flink%2F">Link</a></p> <p><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fsmart-link%2F">Smart link</a></p> </div> <div></div> <div> <p>Edm.String</p> <p>IsURL, url</p> <p>semanticObjectController</p> </div> <div></div> </div> <div> <div>Dates</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fdate-picker%2F">Date picker</a></div> <div> <p>Edm.DateTime</p> <p>sap:display-format=”Date”</p> <p>IsCalendarDate</p> <p>Configuration: controlType</p> </div> <div></div> </div> <div> <div>Dates and times</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fdatetime-picker%2F">Date/time picker</a></div> <div> <p>Edm.DateTime</p> <p>Edm.DateTimeOffset</p> </div> <div></div> </div> <div> <div>Times</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftime-picker%2F">Time picker</a></div> <div>Edm.Time</div> <div></div> </div> <div> <div>Fiscal periods</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Finput-field%2F">Input field</a></div> <div>IsFiscalYear, IsFiscalPeriod,<br>IsFiscalYearPeriod,<br>IsFiscalQuarter, IsFiscalYearQuarter,<br>IsFiscalWeek, IsFiscalYearWeek,<br>IsDayOfFiscalYear</div> <div></div> </div> <div> <div>Amounts with currencies</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div>One or two <a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Finput-field%2F">input fields</a></div> <div>ISOCurrency or sap:unit with sap:semantics=”currency-code”</div> <div></div> </div> <div> <div>Phone numbers</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Finput-field%2F">Input field</a></div> <div>IsPhoneNumber</div> <div></div> </div> <div> <div>Email</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Finput-field%2F">Input field</a></div> <div>IsEmailAddress</div> <div></div> </div> <div> <div>Boolean</div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fcheckbox%2F">Checkbox</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fcheckbox%2F">Checkbox</a></div> <div>Edm.Boolean</div> <div></div> </div> <div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Ftext%2F">Text</a></div> <div><a href="https%3A%2F%2Fwww.sap.com%2Fdesign-system%2Ffiori-design-web%2Fv1-88%2Fui-elements%2Fcombo-box%2F">Combo box</a></div> <div> <p>Edm.Boolean</p> <p>valueList</p> <p>displayBehavior</p> </div> <div> <p>The text in display mode can be influenced via displayBehavior:</p> <ul> <li>Yes/No</li> <li>True/False</li> <li>On/Off</li> </ul> </div> </div>
guideline
  • Set a default value whenever appropriate (annotation: text, property: value).
  • To show a static unit of measurement, use a description (annotation: text).
  • To display a text and ID in the same place, use the format Text (ID) wherever possible. Use another format only if displaying the text doesn’t make any sense. Be careful when using the text arrangement options in tables: end users will only be able to sort, group, or filter based on the ID, even if the ID isn’t visible.
  • If you are not using the smart field within a smart form or smart table, label the smart field with a smart label (annotation: label, properties: textLabel, showLabel). The standard label doesn’t know the inner structure of a smart field.
  • You can set a tooltip (annotation: QuickInfo), but this should usually be avoided. See Using Tooltips.
  • If data entry is expected in a specific format, set a placeholder (property: Placeholder).
hint
Performance: Using the TextArrangement annotation to display both the text and ID (in any order) triggers two requests to the back end.

Behavior and Interaction

Context

You can use the smart field in different contexts
(property: controlContext):

  • Standalone
  • Within a form (depending on the form layout)
  • Within a table (depending on the table type)

The context influences:

  • Labels: In most cases, forms provide the label automatically.
  • Empty values in display mode: In forms, empty values are shown as a dash. In tables, the field remains blank.
  • How units of measurement are displayed
guideline
  • If the width is not handled by the context, set a meaningful width for the smart field, based on the expected data (property: Width).
  • If you use a “standalone” smart field in a form-like arrangement, use a dash to show an empty value in display mode.

Switching Between Edit and Display Mode

Switching between edit and display mode can be controlled manually (annotation: FieldControl, property: editable) or automatically by the containing smart form or smart table (property: contextEditable).

Smart field as a select with 'required' indicator in edit mode

Smart field as a select with 'required' indicator in edit mode

The same smart field in display mode

The same smart field in display mode

guideline
  • Define which fields should be editable (annotations: updateable, creatable, updateable-path, InsertRestrictions, UpdateRestrictions, computed, immutable, fieldControl, fieldControlType).
  • For fields with a unit of measurement, define whether the unit of measurement is editable or static (annotation: FieldControl, property: uomEditable).
  • Make sure that the full text is shown in display mode (property: wrapping), unless this is handled differently for the corresponding context (for example, see guidelines for content in the grid table).
  • When you display the text and ID, the smart field automatically displays both values in display mode, but only the ID in edit mode (annotation: TextArrangement). In most cases, it makes sense to also display both values in edit mode (annotation: sap:text, property: textInEditModeSource, aggregation: Configuration with property: displayBehavior).

Suggestions and Value Help

You can enable suggestions for controls that offer this feature (property: showSuggestions). The list of suggestible values must be provided (annotation: ValueList or ValueListWithFixedValues only for Edm.String, property: entitySet). This list can contain several attributes and is also used for the value help dialog. You can restrict the number of attributes from this list to be shown as suggestions, while all attributes are shown within the value help dialog.

Autocomplete is enabled automatically.

For input fields, the value help dialog is also created automatically. Hide it if it is not needed (property: showValueHelp). The table in the value help dialog can be filled with initial content (annotation: ValueList, property: fetchValues, sap.ui.comp.smartfield.Configuration, property: preventInitialDataFetchInValueHelpDialog)

Both the value help dialog and the suggestion list can be prefiltered (annotation: ValueList, property: valueListParameterIn). The selected items can be used to prefilter other fields (annotation: ValueList, property: ValueListParameterOut). The corresponding filter settings are visible. “Invisible” prefiltering is also supported. To use this option, provide the exact matching filter value (Common.ValueListParameterConstant).

If a value has been entered in the smart field, this value is transferred to the search field of the value help dialog automatically. In the value help dialog, individual values can be valid, deprecated, or revoked. Revoked values are hidden from the value help (annotation: IsConfigurationDeprecationCode).

The following controls are used to offer suggestions or value help:

Smart field as a combo box

Smart field as a combo box

Smart field as an input field with suggestions, auto complete, and a value help button

Smart field as an input field with suggestions, auto complete, and a value help button

The automatically generated value help dialog for the same smart field

The automatically generated value help dialog for the same smart field

Recently Used Values

Input fields, combo boxes, and selects can provide up to five recently used values automatically on focus if suggestions or value help are available. This can be turned on or off per field (property: historyEnabled). Recently used values are shown by default for input fields, but not for combo boxes and selects.
guideline

Do not show recently used values for a field if:

  • There are only a small number of options.
  • The field contains personal sensitive data (annotation: IsPotentiallySensitive).
  • It is unlikely that the same values will be selected again and again.

In addition to recently used values, a smart field can show recommended values (annotation: RecommendationState).

The corresponding smart field is highlighted and/or prefilled:

  • If no recommendation is available or the current user input matches the recommendation, the smart field is shown in the default state.
  • If a recommendation is available and there is no user input, the smart field is shown in the information state.
  • If a recommendation is available and it differs from the current user input, the smart field is displayed in the warning state.

The recommended values are shown as soon as the user focuses on the smart field.

Validation

The smart field offers the following validations automatically:

  • Validation for required fields: This can be done on the client or server side (property: clientSideMandatoryCheck, annotation: Nullable).
  • Validation for a group of fields: Validation is triggered when the focus moves outside a group of fields, rather than when a single field loses the focus. A group is defined by all smart fields that share the same field group ID (property: fieldGroupIds).
  • Validation for the maximum length of user input: Validation is triggered when a field loses the focus or the ENTER key is pressed (property: maxLength).
  • Validation for combo boxes: Checks if the value entered is available in the dropdown list (property: fixedValueListValidationEnabled).

The validation result is indicated by a value state (property: showValueStateMessage).

When the user edits a smart field showing a text and ID, you can allow any kind of input to avoid unnecessary validation issues (annotation: ValueListNoValidation).

Examples:

  • Allowing the user to enter additional values (which are not in the suggestion list)
  • Typing a text instead of an ID to filter down the suggestion list
  • Using the smart field in a draft

Automatic validation

Automatic validation

IDs

The smart field offers automatic validation for number-only ID fields (annotations: IsDigitSequence or sap:display-format="NonNegative"):

  • It checks for non-negative numbers.
  • It shows values containing only “0” digits as empty.
  • It does not show leading zeros.

Units

For decimal number fields and for fields that show an amount with a currency, you can add a unit of measure (annotations: unit, sap-unit with sap:semantics="unit-of-measure" or sap:semantics="currency-code", property: uomVisible). In display mode, the unit is added to the corresponding number. In edit mode, the unit is shown either as text or, if editable, as a second input field (properties: uomEditable, uomEnabled).

Smart field showing an amount with a currency in display mode

Smart field showing an amount with a currency in display mode

The same smart field in display mode

The same smart field in display mode

Sensitive Data

Sensitive data, such as passwords, can be masked. The text is then replaced with asterisks (annotations: IsPotentiallySensitive, masked).

Capitalizing Text Input

Text input can be capitalized automatically (property: IsUpperCase).

States

Smart fields support the following states (annotation: fieldControl):

  • Editable or display only (additional annotations: updateable, creatable, updatable-path, InsertRestrictions, UpdateRestrictions, property: editable)
  • Enabled or disabled
  • Visible or hidden (additional annotations: property: visible, annotation: sap:visible)
  • Required: If set, the smart field must contain a value when validated. This is indicated by an asterisk next to the corresponding label (additional annotation: Nullable, property: mandatory).

The following states for a unit of measurement can be set independently of the corresponding field:

  • If editable, a unit of measurement can be enabled or disabled (property: uomEnabled)
  • The unit of measurement can be visible or hidden (property: uomVisible)
hint
In the SAPUI5 SDK API Reference for the smart field, the display only state is referred to as read only.

Dependencies between Smart Fields

If the content of a smart field is changed, you can trigger additional changes to other fields on the UI (annotation: SideEffects).

Content Alignment

You can change the horizontal alignment of the text within any kind of input field (property: textAlign).
guideline
Follow the alignment rules for the respective context (responsive table, other tables, form). If you are using the standalone option for the smart field (without a context), apply the rules for the corresponding input fields.

Responsiveness

The smart field acts exactly like the embedded controls. For details see:

Top Tips

Properties

The following properties, aggregations, and associations are available for sap.ui.comp.smartfield.SmartField:

Elements and Controls

Implementation

Visual Design