Trap.apex

  • Docs
  • Tutorials
Docs Menu
  • Trigger Handlers
  • Trigger Execution
    • Bulk Objects
    • Functions
    • Data Sharing
  • Trigger Controller

Functions Guide

Functions

updateField

Update the field value of the SObject, by giving a new value or an updating function.

bulkObj.newStream
    .subscribe(Trap.F.updateField.apply('Subject', 'New subject'));

addError

Add an error to the SObject.

bulkObj.newStream
    .subscribe(Trap.F.addError.apply('test error'));

validate

Do validation against the SObject.

bulkObj.newStream
    .subscribe(Trap.F.validate.apply(R.propSatisfies.apply('Subject', R.isNotNull), 'Should not be null'));

getOld

Get the old value.

bulkObj.newStream
    .filter((Func)R.pipe.run(
        Trap.F.getOld,
        new CustomFilterFunc()
    ))
    .subscribe(...);

getNew

Get the new value.

bulkObj.oldStream
    .filter((Func)R.pipe.run(
        Trap.F.getNew,
        new CustomFilterFunc()
    ))
    .subscribe(...);

changed

Check if a field has changed value.

bulkObj.newStream
    .filter(Trap.F.changed.apply('Subject'))
    .subscribe(...);

isEvent

Check current trigger event.

bulkObj.newStream
    .filter(Trap.F.isEvent.apply(Trap.Event.BeforeInsert))
    .subscribe(...);

isBeforeInsert

Check if it is the before insert event.

bulkObj.newStream
    .filter(Trap.F.isBeforeInsert)
    .subscribe(...);

isBeforeUpdate

Check if it is the before update event.

bulkObj.newStream
    .filter(Trap.F.isBeforeUpdate)
    .subscribe(...);

isBeforeDelete

Check if it is the before delete event.

bulkObj.newStream
    .filter(Trap.F.isBeforeDelete)
    .subscribe(...);

isAfterInsert

Check if it is the after insert event.

bulkObj.newStream
    .filter(Trap.F.isAfterInsert)
    .subscribe(...);

isAfterUpdate

Check if it is the after update event.

bulkObj.newStream
    .filter(Trap.F.isAfterUpdate)
    .subscribe(...);

isAfterDelete

Check if it is the after delete event.

bulkObj.newStream
    .filter(Trap.F.isAfterDelete)
    .subscribe(...);

isAfterUndelete

Check if it is the after undelete event.

bulkObj.newStream
    .filter(Trap.F.isAfterUndelete)
    .subscribe(...);

Contribute on Github! Edit this section.