---
url: https://trigger.beyondthecloud.dev/before-insert/record-api.md
description: >-
  What a before insert handler receives - InsertRecord, RejectableInsertRecord
  and InsertRecords - with every method.
---

# Record API in BeforeInsert

## Record {#record}

Type: `TriggerTypes.InsertRecord`. Predicates read the new row and never throw on null.

| Method | In BeforeInsert |
|---|---|
| `getId()` | `null`: not saved yet |
| `getNewSObject()` | the `Trigger.new` row |
| `getNewParent(lookupField)` | the parent loaded by ParentQuery, or `null` |
| `getRelated(providerName)` | rows from a RelatedQuery provider |
| `put(field, value)` | sets a field on the `Trigger.new` row |
| `isRecordType(recordTypeDeveloperName)`, `isNotRecordType` | record type developer name matches / differs |
| `equals(field, value)`, `doesNotEqual` | equal / different; text ignores case |
| `isIn(field, values)`, `isNotIn` | equal to one of the values / to none; text ignores case |
| `contains(field, value)`, `doesNotContain`, `startsWith`, `endsWith` | text match; case-sensitive |
| `isNull(field)`, `isNotNull` | null / not null |
| `isEmpty(field)`, `isNotEmpty` | null or `''` / neither |
| `isBlank(field)`, `isNotBlank` | null, `''` or whitespace / none |
| `isTrue(field)`, `isFalse` | `true` / `false` |
| `greaterThan(field, value)`, `greaterThanOrEqualTo`, `lessThan`, `lessThanOrEqualTo` | number or date comparison; false for null |

`addErrorOnBeforeInsert` gets a `TriggerTypes.RejectableInsertRecord`: no `put`, plus `addError(error)` and `addError(field, error)`.

## Records {#records}

Type: `TriggerTypes.InsertRecords`. `RecordsProvider.query` gets the whole chunk. `finalizeOnBeforeInsert` gets the qualified records.

| Method | In BeforeInsert |
|---|---|
| `getIds()` | always empty: no Id yet |
| `getIdsOf(field)` | non-null Ids in a lookup or Id field |
| `getIdsOf(relationshipName, field)` | Ids in a field of a parent loaded by ParentQuery |
| `getValuesOf(field)` | non-null values of a field, as text |
| `getValuesOf(relationshipName, field)` | values of a field of a parent loaded by ParentQuery, as text |
| `getRecords()` | the records, as `InsertRecord` |
| `size()` | the number of records |

## Rules {#rules}

* **No Id yet.** Key maps by a lookup or a field value, never by `getId()`.
* **Predicates see earlier changes.** They count a value that an earlier handler set with `put`.
* **`0` and `false` are values.** They are not null, empty or blank.
