• 1Installation
  • 2Preliminary Knowledge
  • 3Create Triggers
  • 4Trigger Handler
  • 5Bulk Object
  • 6Find Specific Objects
  • 7Data Sharing
  • 8Catch All Events
  • 9Trigger Controller
  • 10Normal Trigger Event Handler
  • 11Trigger Context
  • 12Unit Test
  • 13Take Only Trigger Execution

Trap.apex

  • Docs
  • Tutorials
Getting started with Trap.apex

Find Specific Objects

Trap.apex makes it clear and convenient to do business logic only to some specific objects. For example, here is how we want to prevent changing the Case subject.

bulkObj.newStream
    .filter(Trap.F.changed('Subject'))
    .subscribe(Trap.F.addError.apply('Cannot modify subject'));

With the power of R.apex, it is possible to compose complicated filter logic like:

Func changed = (Func)R.anyPass.run(
    Trap.F.changed('Subject'),
    Trap.F.changed('OtherField')
);

bulkObj.newStream
    .filter(changed)
    .subscribe(...);
Done