Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A simple and minimal framework for Salesforce Apex triggers management with declarative trigger handlers configuration

License

NotificationsYou must be signed in to change notification settings

AndreyFilonenko/sfdc-declarative-trigger-framework

 
 

Repository files navigation

Example of usage

  1. First, define the settings for AccountTriggerHandler:image

  2. Lets choose beforeInsert and afterInsert methods of AccountTriggerHandler as the targets of test. Also, override the beforeInsert by adding a debug statement:

publicclassAccountTriggerHandlerextendsTriggerHandler {    ...publicoverridevoidbeforeInsert() {super.beforeInsert();System.debug('Overriden beforeInsert method executed!');    }}
  1. Next, add some handlers:
publicclassAccountTriggerHandlerMethod_1implementsCallable {publicObjectcall(Stringaction,Map<String,Object>args) {List<Account>accounts = (List<Account>)args.get('newList');System.debug('AccountTriggerHandlerMethod_1 class executed! ' +accounts.size() +' records passed. - Should be the first method called');returnnull;    }}publicclassAccountTriggerHandlerMethod_2implementsCallable {publicObjectcall(Stringaction,Map<String,Object>args) {List<Account>accounts = (List<Account>)args.get('newList');System.debug('AccountTriggerHandlerMethod_2 class executed! ' +accounts.size() +' records passed.');returnnull;    }}publicclassAccountTriggerHandlerMethod_3implementsCallable {publicObjectcall(Stringaction,Map<String,Object>args) {List<Account>accounts = (List<Account>)args.get('newList');System.debug('AccountTriggerHandlerMethod_3 class executed! ' +accounts.size() +' records passed. - Should be the last method called (before all overrides)');returnnull;    }}publicclassAccountTriggerHandlerMethod_4implementsCallable {publicObjectcall(Stringaction,Map<String,Object>args) {List<Account>accounts = (List<Account>)args.get('newList');System.debug('AccountTriggerHandlerMethod_4 class executed! ' +accounts.size() +' records passed.');returnnull;    }}publicclassAccountTriggerHandlerMethod_5implementsCallable {publicObjectcall(Stringaction,Map<String,Object>args) {List<Account>accounts = (List<Account>)args.get('newList');System.debug('AccountTriggerHandlerMethod_5 class executed! ' +accounts.size() +' records passed.');returnnull;    }}
  1. ...and register them as handlers in Custom metadata:image

  2. To trigger the test just execute this in anonymous:

Accountacc =newAccount();acc.Name ='Test';insertacc;
  1. The results are below:image

All needed classes and example handlers are included in this branch and can be used for other tests.

About

A simple and minimal framework for Salesforce Apex triggers management with declarative trigger handlers configuration

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp