Gets a field’s value from a record. Spanning fields are supported.
The field’s value is returned in its raw data form. In some cases, the raw data form differs from the display value that’s returned by
record—(Required) A Record object from which to retrieve the field value.
field—(Required) The API name of the field. The value can be either a string or reference to a field imported from
@salesforce/schema. You can specify up to 5 levels of spanning fields. For example,
Opportunity.Account.CreatedBy.LastModifiedByIdreturns 4 levels of spanning fields.
The field’s value. A record may be returned if a spanning field is used. If the field you are requesting for doesn’t exist, this function returns
To get the value of a record’s field, you can use the getRecord wire adapter, which returns the property
record.data.fields.fieldName.value. However, you can also call
getFieldValue(record, field) to get the value directly.
The field value is returned in its raw data form, which is useful for calculations and comparisons. Here are a few examples of values in raw data form:
- Currency values are displayed like
- Date values are displayed like
- Date/time values are displayed like
Import the field references that you pass to
getFieldValue(record, field) from the
@salesforce/schema scoped package.
The base components display the values:
Wednesday, Jun 17, 2015, 03:17 PM
Jul 13, 2014
Alternatively, use the
getFieldDisplayValue(record, field) wire adapter to display the formatted and localized value for a field.