---
schema_version: "1"
id: 776e9a45507ed4c7945238eae2b17642a6231856bf72ac7f647705cebf60078f
title: Interface RecordAccessor
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforce-functions/functions/guide/javasdk/interfaces/java-recordaccessor.md
canonical_url: https://developer.salesforce.com/docs/platform/functions/guide/java-recordaccessor.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 212f2aca34bc50c891efa63612792de69d3777bf67084baf597e0aa36ece09e4
products:
  - Salesforce Functions
---
# Interface RecordAccessor

All Known Subinterfaces: `Record`, `RecordBuilder`

---

public interface RecordAccessor

Allows to access Salesforce record data.

See Also: `Record`, `RecordBuilder`

## Method Summary

| Modifier and Type                          | Method                                      | Description                                                                                                  |
| ------------------------------------------ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `java.util.Optional<java.math.BigDecimal>` | `getBigDecimalField(java.lang.String name)` | Returns the value of a field as a `BigDecimal`.                                                              |
| `java.util.Optional<java.math.BigInteger>` | `getBigIntegerField(java.lang.String name)` | Returns the value of a field as a `BigInteger` which may involve rounding.                                   |
| `java.util.Optional<java.nio.ByteBuffer>`  | `getBinaryField(java.lang.String name)`     | Returns the value of a binary field as a `ByteBuffer`.                                                       |
| `java.util.Optional<java.lang.Boolean>`    | `getBooleanField(java.lang.String name)`    | Returns the value of a field as a `Boolean`.                                                                 |
| `java.util.Optional<java.lang.Byte>`       | `getByteField(java.lang.String name)`       | Returns the value of a field as a `Byte`, which may involve rounding or truncation.                          |
| `java.util.Optional<java.lang.Double>`     | `getDoubleField(java.lang.String name)`     | Returns the value of a field as a `Double`, which may involve rounding or truncation.                        |
| `java.util.Set<java.lang.String>`          | `getFieldNames()`                           | Returns the names of all fields present in this record.                                                      |
| `java.util.Optional<java.lang.Float>`      | `getFloatField(java.lang.String name)`      | Returns the value of a field as a `Float`, which may involve rounding or truncation.                         |
| `java.util.Optional<java.lang.Integer>`    | `getIntField(java.lang.String name)`        | Returns the value of a field as an `Integer`, which may involve rounding or truncation.                      |
| `java.util.Optional<java.lang.Long>`       | `getLongField(java.lang.String name)`       | Returns the value of a field as a `Long`, which may involve rounding or truncation.                          |
| `java.util.Optional<Record>`               | `getRecordField(java.lang.String name)`     | Returns the value of the record field as a `Record` or empty `Optional` if the field is not present or null. |
| `java.util.Optional<java.lang.Short>`      | `getShortField(java.lang.String name)`      | Returns the value of a field as a `Short`, which may involve rounding or truncation.                         |
| `java.util.Optional<java.lang.String>`     | `getStringField(java.lang.String name)`     | Returns the value of a field as a `String`.                                                                  |
| `java.lang.String`                         | `getType()`                                 | Returns the type of this record.                                                                             |
| `boolean`                                  | `hasField (java.lang.String name)`          | Returns if this record has a field with the given name.                                                      |
| `boolean`                                  | `isNullField(java.lang.String name)`        | Returns if this record has a field with the given name that has `null` as its value.                         |

## Method Details

### getType

\@Nonnull java.lang.String getType()

Returns the type of this record.

Returns: The type of this record.

Returns the type of this record.

\@Nonnull java.util.Set\<java.lang.String\> getFieldNames()

Returns the names of all fields present in this record.

This includes fields that have null as their value.

Returns: The names of all fields present in this record.

\@Nonnull java.util.Set\<java.lang.String\> getFieldNames()

boolean hasField​(java.lang.String name)

Returns if this record has a field with the given name. The field name
is compared case-insensitively.

This includes fields that have null as their value.

Parameters: `name` - The name of the field to check. Returns: If this
record has a field with the given name.

Returns: The names of all fields present in this record.

boolean isNullField​(java.lang.String name)

Returns if this record has a field with the given name that has `null`
as its value. The field name is compared case-insensitively.

If there is no field with the given name, false is returned.

Parameters: `name` - The name of the field to check. Returns: If this
record has a field with the given name that has `null` as its value.

Returns if this record has a field with the given name. The field name
is compared case-insensitively.

\@Nonnull
java.util.Optional\<java.lang.String\> getStringField​(java.lang.String name)

Returns the value of a field as a `String`. The field name is compared
case-insensitively.

Field values that are not `String`s will be automatically converted to
Strings. For example, if the field contains the number 42, this method
will return an `Optional` that contains the String \"42\".

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `String` or empty `Optional` if the
field is not present or null.

### getBooleanField

\@Nonnull
java.util.Optional\<java.lang.Boolean\> getBooleanField​(java.lang.String name)

Returns the value of a field as a `Boolean`. The field name is compared
case-insensitively.

If the field is not a boolean, its value is converted to a `String`
first, and then parsed with `Boolean.parseBoolean(String)`. Effectively,
this means that any non-boolean value except the String \"true\"
(compared case-insensitive) will result in false being returned by this
method.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `Boolean` or empty `Optional` if
the field is not present or null.

### getByteField

\@Nonnull
java.util.Optional\<java.lang.Byte\> getByteField​(java.lang.String name)

Returns the value of a field as a `Byte`, which may involve rounding or
truncation. The field name is compared case-insensitively.

If field\'s value is not a number, this method will try to parse it as
one. This allows `String`s that represent numbers to be interpreted as
numbers. If the value cannot be parsed as a number, a
`NumberFormatException` is thrown.

If the (if necessary, parsed) value cannot be directly represented as a
`Byte` (i.e. the value is too large or contains decimals), it will be
converted to a `Byte` which may involve rounding or truncation of the
value.

The conversion is analogous to a narrowing primitive conversion or a
widening primitive conversion as defined in The Java® Language
Specification for converting between primitive types. Therefore,
conversions may lose information about the overall magnitude of a
numeric value, may lose precision, and may even return a result of a
different sign.

If full control over the conversion is required,
`getBigDecimalField(String)` can be used. `BigDecimal` offers an
extensive suite of methods to convert from a `BigDecimal` to primitive
number types.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `Byte` or empty `Optional` if the
field is not present or null.
Throws: `java.lang.NumberFormatException` If the value could not be parsed as a `Byte` value.
See Also:

- [The Java Language Specification - Chapter 5. Conversions and Contexts](https://docs.oracle.com/javase/specs/jls/se11/html/jls-5.html)
- [`getBigDecimalField(String)`](#getbigdecimalfield)

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `String` or empty `Optional` if the
field is not present or null.

\@Nonnull
java.util.Optional\<java.lang.Short\> getShortField​(java.lang.String name)

Returns the value of a field as a `Short`, which may involve rounding or
truncation. The field name is compared case-insensitively.

If field\'s value is not a number, this method will try to parse it as
one. This allows `String`s that represent numbers to be interpreted as
numbers. If the value cannot be parsed as a number, a
`NumberFormatException` is thrown.

If the (if necessary, parsed) value cannot be directly represented as a
`Short` (i.e. the value is too large or contains decimals), it will be
converted to a `Short` which may involve rounding or truncation of the
value.

The conversion is analogous to a narrowing primitive conversion or a
widening primitive conversion as defined in The Java® Language
Specification for converting between primitive types. Therefore,
conversions may lose information about the overall magnitude of a
numeric value, may lose precision, and may even return a result of a
different sign.

If full control over the conversion is required,
`getBigDecimalField(String)` can be used. `BigDecimal` offers an
extensive suite of methods to convert from a `BigDecimal` to primitive
number types.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `Short` or empty `Optional` if the
field is not present or null.
Throws: `java.lang.NumberFormatException` If the value could not be parsed as a `Short` value.
See Also:

- [The Java Language Specification - Chapter 5. Conversions and Contexts](https://docs.oracle.com/javase/specs/jls/se11/html/jls-5.html)
- [`getBigDecimalField(String)`](#getbigdecimalfield)

### getIntField

\@Nonnull
java.util.Optional\<java.lang.Integer\> getIntField​(java.lang.String name)

Returns the value of a field as an `Integer`, which may involve rounding
or truncation. The field name is compared case-insensitively.

If field\'s value is not a number, this method will try to parse it as
one. This allows `String`s that represent numbers to be interpreted as
numbers. If the value cannot be parsed as a number, a
`NumberFormatException` is thrown.

If the (if necessary, parsed) value cannot be directly represented as an
`Integer` (i.e. the value is too large or contains decimals), it will be
converted to an `Integer` which may involve rounding or truncation of
the value.

The conversion is analogous to a narrowing primitive conversion or a
widening primitive conversion as defined in The Java® Language
Specification for converting between primitive types. Therefore,
conversions may lose information about the overall magnitude of a
numeric value, may lose precision, and may even return a result of a
different sign.

If full control over the conversion is required,
`getBigDecimalField(String)` can be used. `BigDecimal` offers an
extensive suite of methods to convert from a `BigDecimal` to primitive
number types.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as an `Integer` or empty `Optional` if
the field is not present or null.
Throws: `java.lang.NumberFormatException` If the value could not be parsed as
an `Integer` value.
See also:

- [The Java Language Specification - Chapter 5. Conversions and Contexts](https://docs.oracle.com/javase/specs/jls/se11/html/jls-5.html)
- [`getBigDecimalField(String)`](#getbigdecimalfield)

### getLongField

\@Nonnull
java.util.Optional\<java.lang.Long\> getLongField​(java.lang.String name)

Returns the value of a field as a `Long`, which may involve rounding or
truncation. The field name is compared case-insensitively.

If field\'s value is not a number, this method will try to parse it as
one. This allows `String`s that represent numbers to be interpreted as
numbers. If the value cannot be parsed as a number, a
`NumberFormatException` is thrown.

If the (if necessary, parsed) value cannot be directly represented as a
`Long` (i.e. the value is too large or contains decimals), it will be
converted to a `Long` which may involve rounding or truncation of the
value.

The conversion is analogous to a narrowing primitive conversion or a
widening primitive conversion as defined in The Java® Language
Specification for converting between primitive types. Therefore,
conversions may lose information about the overall magnitude of a
numeric value, may lose precision, and may even return a result of a
different sign.

If full control over the conversion is required,
`getBigDecimalField(String)` can be used. `BigDecimal` offers an
extensive suite of methods to convert from a `BigDecimal` to primitive
number types.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `Long` or empty `Optional` if the
field is not present or null.
Throws: `java.lang.NumberFormatException` If the value could not be parsed as a `Long` value.
See Also:

- [The Java Language Specification - Chapter 5. Conversions and Contexts](https://docs.oracle.com/javase/specs/jls/se11/html/jls-5.html)
- [`getBigDecimalField(String)`](#getbigdecimalfield)

### getFloatField

\@Nonnull
java.util.Optional\<java.lang.Float\> getFloatField​(java.lang.String name)

Returns the value of a field as a `Float`, which may involve rounding or
truncation. The field name is compared case-insensitively.

If field\'s value is not a number, this method will try to parse it as
one. This allows `String`s that represent numbers to be interpreted as
numbers. If the value cannot be parsed as a number, a
`NumberFormatException` is thrown.

If the (if necessary, parsed) value cannot be directly represented as a
`Float` (i.e. the value is too large or contains decimals), it will be
converted to a `Float` which may involve rounding or truncation of the
value.

The conversion is analogous to a narrowing primitive conversion or a
widening primitive conversion as defined in The Java® Language
Specification for converting between primitive types. Therefore,
conversions may lose information about the overall magnitude of a
numeric value, may lose precision, and may even return a result of a
different sign.

If full control over the conversion is required,
`getBigDecimalField(String)` can be used. `BigDecimal` offers an
extensive suite of methods to convert from a `BigDecimal` to primitive
number types.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `Float` or empty `Optional` if the
field is not present or null.
Throws: `java.lang.NumberFormatException` If the value could not be parsed as a `Float` value.
See Also:

- [The Java Language Specification - Chapter 5. Conversions and Contexts](https://docs.oracle.com/javase/specs/jls/se11/html/jls-5.html)
- [`getBigDecimalField(String)`](#getbigdecimalfield)

### getDoubleField

\@Nonnull
java.util.Optional\<java.lang.Double\> getDoubleField​(java.lang.String name)

Returns the value of a field as a `Double`, which may involve rounding
or truncation. The field name is compared case-insensitively.

If field\'s value is not a number, this method will try to parse it as
one. This allows `String`s that represent numbers to be interpreted as
numbers. If the value cannot be parsed as a number, a
`NumberFormatException` is thrown.

If the (if necessary, parsed) value cannot be directly represented as a
`Double` (i.e. the value is too large or contains decimals), it will be
converted to a `Double` which may involve rounding or truncation of the
value.

The conversion is analogous to a narrowing primitive conversion or a
widening primitive conversion as defined in The Java® Language
Specification for converting between primitive types. Therefore,
conversions may lose information about the overall magnitude of a
numeric value, may lose precision, and may even return a result of a
different sign.

If full control over the conversion is required,
`getBigDecimalField(String)` can be used. `BigDecimal` offers an
extensive suite of methods to convert from a `BigDecimal` to primitive
number types.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `Double` or empty `Optional` if the
field is not present or null.
Throws: `java.lang.NumberFormatException` If the value could not be parsed as a `Double` value.
See Also:

- [The Java Language Specification - Chapter 5. Conversions and Contexts](https://docs.oracle.com/javase/specs/jls/se11/html/jls-5.html)
- [`getBigDecimalField(String)`](#getbigdecimalfield)

### getBigIntegerField

\@Nonnull
java.util.Optional\<java.math.BigInteger\> getBigIntegerField​(java.lang.String name)

Returns the value of a field as a `BigInteger` which may involve
rounding. The field name is compared case-insensitively.

If field\'s value is not a number, this method will try to parse it as
one. If that process fails, a `NumberFormatException` is thrown.

If the (if necessary, parsed) value cannot be directly represented as a
`BigInteger` (i.e. the value contains decimals), it will be converted to
a `BigInteger` which may involve rounding. Use
`getBigDecimalField(String)` support for decimals is required.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `BigInteger` or empty `Optional` if
the field is not present or null.
Throws: `java.lang.NumberFormatException` If the value could not be parsed as
a `BigInteger` value.
See Also: [`getBigDecimalField(String)`](#getbigdecimalfield)

### getBigDecimalField

\@Nonnull
java.util.Optional\<java.math.BigDecimal\> getBigDecimalField​(java.lang.String name)

Returns the value of a field as a `BigDecimal`. The field name is
compared case-insensitively.

If the field\'s value is not a number, this method will try to parse it
as one. If that process fails, or the number cannot be represented as a
`BigDecimal`, a `NumberFormatException` is thrown.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the field as a `BigDecimal` or empty `Optional` if
the field is not present or null.
Throws: `java.lang.NumberFormatException` If the value could not be parsed as
a `BigDecimal` value.

### getBinaryField

\@Nonnull Optional\<java.nio.ByteBuffer\> getBinaryField​(java.lang.String name)

Returns the value of a binary field as a `ByteBuffer`. The field name is
compared case-insensitively.

Only field values that are binary data are converted to a
`ByteBuffer`. If you use this method on a non-binary field then a
`FieldConversionException` is thrown.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the binary field as a `ByteBuffer` or empty
`Optional` if the field isn't present or is null. 
Throws:`FieldConversionException` if the value isn't binary data.

### getRecordField

\@Nonnull Optional\<Record\> getRecordField​(java.lang.String name)

Returns the value of a record field as a `Record`. The field name is
compared case-insensitively.

Only field values that are record data are converted to a
`Record`. If you use this method on a non-record field then a
`FieldConversionException` is thrown.

Parameters: `name` - The name of the field to obtain the value from.
Returns: The value of the record field as a `Record` or empty `Optional`
if the field isn't present or is null. 
Throws: `FieldConversionException` if the value isn't record data.
