Skip to content
pozil edited this page Nov 14, 2024 · 10 revisions

Safely Class

Class wraps DML Calls in FLS / Crud checks. Library is baseed on a fluent api system. All calls are constructed, then chained with options. For instances. new Safely().allOrNothing().doInsert(List<sObject>);

Notable chainable methods include:

  • allOrNothing() - this enforces the AllOrNothing DML flag. All DML is eventually executed via Database.* methods which accept an allOrNothing parameter requiring all of the records to succeed or fail.
  • throwIfRemovedFields() - this method, if called, will result in an exception being thrown if any record being modified has fields removed by the security decision.

Fields

allOrNothing

TESTVISIBLE

Signature

private allOrNothing

Type

Boolean


throwIfRemovedFields

TESTVISIBLE

Signature

private throwIfRemovedFields

Type

Boolean

Methods

allOrNothing()

Signature

public Safely allOrNothing()

Return Type

Safely


throwIfRemovedFields()

Signature

public Safely throwIfRemovedFields()

Return Type

Safely


doInsert(records)

Signature

public List<Database.SaveResult> doInsert(List<SObject> records)

Parameters

Name Type Description
records List<SObject>

Return Type

List<Database.SaveResult>


doInsert(record)

Signature

public List<Database.SaveResult> doInsert(SObject record)

Parameters

Name Type Description
record SObject

Return Type

List<Database.SaveResult>


doUpdate(records)

Signature

public List<Database.SaveResult> doUpdate(List<SObject> records)

Parameters

Name Type Description
records List<SObject>

Return Type

List<Database.SaveResult>


doUpdate(record)

Signature

public List<Database.SaveResult> doUpdate(SObject record)

Parameters

Name Type Description
record SObject

Return Type

List<Database.SaveResult>


doUpsert(records)

Signature

public List<Database.UpsertResult> doUpsert(List<SObject> records)

Parameters

Name Type Description
records List<SObject>

Return Type

List<Database.UpsertResult>


doUpsert(record)

Signature

public List<Database.UpsertResult> doUpsert(Sobject record)

Parameters

Name Type Description
record Sobject

Return Type

List<Database.UpsertResult>


doDelete(records)

Signature

public List<Database.DeleteResult> doDelete(List<SObject> records)

Parameters

Name Type Description
records List<SObject>

Return Type

List<Database.DeleteResult>


doDelete(record)

Signature

public List<Database.DeleteResult> doDelete(SObject record)

Parameters

Name Type Description
record SObject

Return Type

List<Database.DeleteResult>


doQuery(query)

Signature

public List<SObject> doQuery(String query)

Parameters

Name Type Description
query String

Return Type

List<SObject>


doDML(accessType, records)

Signature

private List<Database.SaveResult> doDML(System.AccessType accessType, List<SObject> records)

Parameters

Name Type Description
accessType System.AccessType
records List<SObject>

Return Type

List<Database.SaveResult>


guardAgainstRemovedFields(accessType, records)

Signature

private SObjectAccessDecision guardAgainstRemovedFields(System.AccessType accessType, List<SObject> records)

Parameters

Name Type Description
accessType System.AccessType
records List<SObject>

Return Type

SObjectAccessDecision

Classes

RemovedFieldsException Class

Clone this wiki locally