---
schema_version: "1"
id: 8cd6de0a3154e1e32ee6ed2f6c105458d5c567f2a9d0a6504720a67c74789256
title: Interface UnitOfWorkBuilder
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforce-functions/functions/guide/javasdk/interfaces/java-unitofworkbuilder.md
canonical_url: https://developer.salesforce.com/docs/platform/functions/guide/java-unitofworkbuilder.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: c14857e6410419c5a49bd914479e03435ce6eca8e89644b4d4f62df3a4ea77a4
products:
  - Salesforce Functions
---
# Interface UnitOfWorkBuilder

------------------------------------------------------------------------

public interface UnitOfWorkBuilder

Builder for `UnitOfWork`.

See Also: `DataApi.newUnitOfWorkBuilder()`

## Method Summary

| Modifier and Type                                                                   | Method                                                               | Description                                                                                                                                                               |
| ----------------------------------------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UnitOfWork`              | `build()`                                                            | Returns a new and immutable `UnitOfWork` instance based on the information stored in this builder.                                                                            |
| `ReferenceId`             | `registerCreate(Record record)`                                      | Registers a record creation for the `UnitOfWork` and returns a `ReferenceId` that can be used to refer to the created record in subsequent operations in this UnitOfWork. |
| `ReferenceId` | `registerDelete(java.lang.String type, java.lang.String id)`               | Registers a deletion of an existing record of the given type and id. |
| `ReferenceId`    | `registerUpdate(Record record)`                                      | Registers a record update for the `UnitOfWork` and returns a `ReferenceId` that can be used to refer to the updated record in subsequent operations in this UnitOfWork. |

## Method Details

### registerCreate

\@Nonnull ReferenceId registerCreate​(Record record)

Registers a record creation for the `UnitOfWork` and returns a
`ReferenceId` that can be used to refer to the created record in
subsequent operations in this UnitOfWork.

Parameters: `record` - The record to create. Returns: The ReferenceId
for the created record. Throws: `java.lang.IllegalArgumentException` -
If the `Record` instance wasn\'t created by a `RecordBuilder` obtained
from same `DataApi` instance this UnitOfWorkBuilder was obtained from.

### registerUpdate

\@Nonnull ReferenceId registerUpdate​(Record record)

Registers a record update for the `UnitOfWork` and returns a
`ReferenceId` that can be used to refer to the updated record in
subsequent operations in this UnitOfWork.

Parameters: `record` - The record to update. Returns: The ReferenceId
for the updated record. Throws: `java.lang.IllegalArgumentException` -
If the `Record` instance wasn\'t created by a `RecordBuilder` obtained
from same `DataApi` instance this UnitOfWorkBuilder was obtained from.

### registerDelete

\@Nonnull ReferenceId registerDelete​(java.lang.String type,
java.lang.String id)

Registers a deletion of an existing record of the given type and id.

Parameters: `type` - The object type of the record to delete. `id` - The
id of the record to delete. Returns: The ReferenceId for the deleted
record.

### build

\@Nonnull UnitOfWork build()

Returns a new and immutable `UnitOfWork` instance based on the
information stored in this builder.

Returns: The new `UnitOfWork` instance.
