Field Path Expressions
Field path expressions represent the location of a field or value within a record. They can be parsed from a string using FieldPath.parse(String) or created programmatically by adding name (FieldPath.name(String)) and index (FieldPath.index(int)) segments to a
For example, the field path customer.address.city can be created in two ways:
|Single field names||firstName|
|Nested field names||customer.firstName|
|Positional field access — since city is the first field in the address record, it can be referenced at position zero ()||customer.address|
|Positional field access — fields in the root record can also be accessed by their position. For example, the second field would be at position one ()|||
|String array indices can be used to reference fields with spaces and special characters in their names. Both double and single quotes can be used to surround string array indices.||customer.address["zip code"]
|Quoted field names (for field names with spaces or symbols)||'Company Flag (Y/N)'|
|Quoted nested field names (for field names with spaces or symbols)||customer."Company Flag (Y/N)"|
|Quoted array values (for field names with spaces or symbols)||`Company Address`|
Identifiers in field expressions may start with letters, underscores (_), at symbols (@), or dollar signs ($) and contain letters, numbers, underscores, at symbols, and dollar signs. You will need to quote field expressions that contain other symbols and spaces if they should be treated as part of the field name. For example, if your field name contains a period, you will need to quote it ("Package Lbs.").
When quoting fields, you can use double quotes ("), single quotes ('), or grave accent (`).
Caution With Array Values
A note of caution: FieldPath can also represent the location of values in array fields. For example,
customer.address.city could match the third city in an array field. Some methods and operations expecting a field will throw an exception (or return false) if the supplied FieldPath matches an array value and not a field.