---
url: https://trigger.beyondthecloud.dev/before-delete/record-api.md
description: >-
  What a before delete Validator or Writer receives - DeleteRecord,
  RejectableDeleteRecord and DeleteRecords - with every method.
---

# Record API in BeforeDelete

## Record {#record}

Type: `TriggerTypes.DeleteRecord`. Predicates read the old row and never throw on null.

| Method | In BeforeDelete |
|---|---|
| `getId()` | the record Id |
| `getOldSObject()` | the `Trigger.old` row, read-only |
| `getOldParent(lookupField)` | the old row's parent, loaded by PriorParentQuery, or `null` |
| `getRelated(providerName)` | rows from a RelatedQuery provider |
| `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 |

`addErrorOnBeforeDelete` gets a `TriggerTypes.RejectableDeleteRecord`: the same methods, plus `addError(error)` and `addError(field, error)`.

## Records {#records}

Type: `TriggerTypes.DeleteRecords`. `RecordsProvider.query` gets the whole chunk. `finalizeOnBeforeDelete` gets the qualified records.

| Method | In BeforeDelete |
|---|---|
| `getIds()` | the record Ids |
| `getIdsOf(field)` | non-null Ids in a lookup or Id field |
| `getIdsOf(relationshipName, field)` | Ids in a field of a parent loaded by PriorParentQuery |
| `getValuesOf(field)` | non-null values of a field, as text |
| `getValuesOf(relationshipName, field)` | values of a field of a parent loaded by PriorParentQuery, as text |
| `getRecords()` | the records, as `DeleteRecord` |
| `size()` | the number of records |

## Rules {#rules}

* **Read-only, but takes errors.** Writing to `getOldSObject()` throws. A Validator's `record.addError('…')` blocks the delete of that record.
* **Lookups hold only the Id.** `((Contact) record.getOldSObject()).Account` is null. Declare a [PriorParentQuery](/before-delete/add-ons/prior-parent-query) and read `getOldParent(Contact.AccountId)`.
* **No merge winner yet.** `MasterRecordId` is set only in [AfterDelete](/after-delete/record-api).
