Foundations Apex API Developer Reference

fferpcore.ihcc_ISObjectUnitOfWork

global interface ihcc_ISObjectUnitOfWork

Representation of a Unit of Work that can be passed between namespaces. Allows ihcc to provide a UoW that respects process limits to the integration implementations. This is based on fflib_ISObjectUnitOfWork but not all methods are provided/supported

Methods

registerNew

void registerNew(SObject record)

Register a newly created SObject instance to be inserted when commitWork is called

Input Parameters

Name Type Description
record SObject A newly created SObject instance to be inserted during commitWork

registerNew

void registerNew(list<SObject> records)

Convenience method to register a list of newly created SObject instances to be inserted when commitWork is called

Input Parameters

Name Type Description
records list<SObject> An list of newly created SObject instances to be inserted during commitWork

registerNew

void registerNew(SObject record, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord)

Register a newly created SObject instance to be inserted when commitWork is called, you may also provide a reference to the parent record instance (should also be registered as new separately)

Input Parameters

Name Type Description
record SObject A newly created SObject instance to be inserted during commitWork
relatedToParentField Schema.SObjectField A SObjectField reference to the child field that associates the child record with its parent
relatedToParentRecord SObject A SObject instance of the parent record (should also be registered as new separately)

registerNew

void registerNew(list<SObject> records, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord)

Convenience method to register a list of newly created SObject instances to be inserted when commitWork is called

Input Parameters

Name Type Description
records list<SObject> An list of newly created SObject instances to be inserted during commitWork
relatedToParentField Schema.SObjectField A SObjectField reference to the child field that associates the child record with its parent
relatedToParentRecord SObject A SObject instance of the parent record (should also be registered as new separately)

registerRelationship

void registerRelationship(SObject record, Schema.SObjectField relatedToField, SObject relatedTo)

Register a relationship between two records that have yet to be inserted to the database. This information will be used during the commitWork phase to make the references only when related records have been inserted to the database.

Input Parameters

Name Type Description
record SObject An existing or newly created record
relatedToField Schema.SObjectField A SObjectField referene to the lookup field that relates the two records together
relatedTo SObject A SObject instance (yet to be commited to the database)

registerRelationship

void registerRelationship(List<SObject> records, Schema.SObjectField relatedToField, SObject relatedTo)

Register relationships between one or more records to the RelatedTo record, where the relatedToRecord is yet to be inserted to the database. This information will be used during the commitWork phase to make the references only when related records have been inserted to the database.

Input Parameters

Name Type Description
records List<SObject> Existing or newly created records of the same SObjectType
relatedToField Schema.SObjectField A SObjectField reference to the lookup field that relates the child records to the parent
relatedTo SObject The relationship target record which is awaiting insert. The supplied records will have the relationship field updated to this value after the target record is assigned an ID.

registerDirty

void registerDirty(SObject record)

Register an existing record to be updated during the commitWork method

Input Parameters

Name Type Description
record SObject An existing record

registerDirty

void registerDirty(list<SObject> records)

Convenience method to register a list of existing methods to be updated during the commitWork method

Input Parameters

Name Type Description
records list<SObject> An existing list of records

registerDeleted

void registerDeleted(SObject record)

Register an existing record to be deleted during the commitWork method

Input Parameters

Name Type Description
record SObject An existing record

registerDeleted

void registerDeleted(list<SObject> records)

Convenience method to register a list of existing methods to be deleted during the commitWork method

Input Parameters

Name Type Description
records list<SObject> An existing list of records

commitAllWork

List<ihcc_IDatabaseResult> commitAllWork()

Takes all the work that has been registered with the UnitOfWork and commits it to the database. All DML will be run using the database instance passed (in the sharing mode of that database). Always executes in partial success mode.

Return Value

A list of fflib_DatabaseResults denoting save success/failure alongside any error messages for each SObject record. If the same record is involved in multiple DML operations, including if additional updates are added inside the commitWork for relationship resolving, then an fflib_DatabaseResult will be returned for each operation.

© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.