0

I am trying to implement the Trigger Handler Framework as seen here: https://www.salesforceben.com/the-salesforce-trigger-handler-framework/. It uses the following model 'Helper + Interface + Handler + Trigger'. I have saved the Trigger, the Handler, the Interface, and Helper and am trying to update the Helper file in order to create a simple Before Update trigger on the Account object.

Account Trigger Helper class:

public without sharing class AccountTriggerHelper {
public AccountTriggerHelper() {
    System.debug('Inside AccountTriggerHelper Constructor');
}
public void doTask1(List<Account> newAccounts) {
   List<Account> accountList = new List<Account>();
   for(Account acc : newAccounts){
   acc.Phone = '222-222-2222';
   accountList.add(acc);
   }
   UPDATE accountList;
   System.debug('Inside Task 1');
}

Account Trigger Handler class:

public without sharing class AccountTriggerHandler implements TriggerHandler {
private boolean triggerIsExecuting;
private integer triggerSize;
public AccountTriggerHelper helper;
public AccountTriggerHandler(boolean triggerIsExecuting, integer triggerSize) {
    this.triggerIsExecuting = triggerIsExecuting;
    this.triggerSize = triggerSize;
    this.helper = new AccountTriggerHelper();
}
public void beforeInsert(List<Account> newAccounts) {
    helper.doTask1();
    helper.doTask2();
}

However, I am getting the following error:

Method does not exist or incorrect signature: void doTask1() from the type AccountTriggerHelper

1 Answer 1

2

The doTask1 method defined at AccountTriggerHelper expects a List but you're not passing any as argument when you call it from the beforeInsert method.

Instead you should have:

public void beforeInsert(List<Account> newAccounts) {
    helper.doTask1(newAccounts);
}
5
  • Yep, the error spells this one out pretty clearly.
    – Derek F
    Apr 26, 2022 at 15:05
  • Thank you. This did the trick
    – spal
    Apr 26, 2022 at 15:22
  • @SpyridonPallis If your issue has been solved, you should accept the answer (or whichever answer you think helped you the most, if you received multiple). It's part of the stackexchange culture. It gives both you and the person who provided the answer reputation points, signals to the community that you don't need further help with this question, and helps other people with similar questions find solutions that are likely to work.
    – Derek F
    Apr 26, 2022 at 19:43
  • Hey Derek, I tried to accept it but it says I need 15 reputation.
    – spal
    Apr 26, 2022 at 19:55
  • @SpyridonPallis Upvoting requires 15 rep. There is no reputation requirement for accepting answers (which is the checkmark you see under the upvote/downvote arrows).
    – Derek F
    May 1, 2022 at 1:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .