0

I am not sure if there is something small I am missing but whenever I try to deploy I get this error:

Failure AllLeadTriggers ApexTrigger Invalid type: LeadDeDuplicationHelper (line:5)

My trigger is very simple:

trigger AllLeadTriggers on Lead (before insert, after insert, before update, after update, before delete, after delete) {
if (Trigger.isBefore) {
    if (Trigger.isInsert) {
        LeadDeDuplicationHelper ldh = new LeadDeDuplicationHelper();
        ldh.handleDuplicates(Trigger.new);
    } 
    if (Trigger.isUpdate) {
        // ** Call class logic here! **
      } 
    if (Trigger.isDelete) {
        // ** Call class logic here! **
      } 
} else if (Trigger.isAfter) {
    if (Trigger.isInsert) {
        // ** Call class logic here! **
    } 
    if (Trigger.isUpdate) {
      // ** Call class logic here! **
    }
    if (Trigger.isDelete) {
      // ** Call class logic here! **
    }
}
}

my class starts like this:

public with sharing class LeadDeDuplicationHelper {
    public void handleDuplicates(List<Lead> newLeadList){
       logic here...
    }
}

and my test class is passing both at 100%.

If there was a syntax error my test class wouldn't pass and I shouldn't have to declare it as global or static to call from a trigger. There are no callouts happening in the logic...I am stumped. I am using gearset to deploy so perhaps there is something going on with that tool. Any ideas?

Update: I have tried deploying the apex class and test class first and then the trigger but it still fails with the same error. I have also deployed with all of them together and get the same error. The API versions are all 55.0 and they are all listed as active.

5
  • 1
    In typical best practice implementations, you still have too much code in the trigger itself. Ideally you should move everything possible to a handler class and boil the logic in the trigger down to simply switch on triggerOperation { when BEFORE_INSERT { handle.beforeInsert(); } }.
    – Adrian Larson
    Oct 21, 2022 at 17:00
  • @AdrianLarson do you think that this is causing the deployment to fail?
    – Olivia
    Oct 21, 2022 at 17:15
  • If using Gearset, is this an org-to-org compare/deploy or an org-to-VCS deploy followed by a CI job that does VCS-to-org deploy?
    – cropredy
    Oct 21, 2022 at 17:47
  • org to VCS with a CI job. The org to branch deploy works. The CI job fails so it's something about the org that doesn't like it.
    – Olivia
    Oct 21, 2022 at 18:04
  • It would have no functional impact, just better architecture, readability, maintenance, etc.
    – Adrian Larson
    Oct 21, 2022 at 19:35

2 Answers 2

0

Make sure you are adding your apex class in the deployment. By seeing the error the most probable reason is that you are not adding apex class in the deployment.

If you are adding then try deploying apex class first and then trigger.

3
  • I have tried deploying the apex class and test class first and then the trigger but it still fails with the same error. I have also deployed with all of them together and get the same error.
    – Olivia
    Oct 21, 2022 at 17:00
  • Did you change your apex class name? Like you created in small letter than to capital. You can try deleting this class and create a new class with same name. Oct 21, 2022 at 17:02
  • I did not change the name but I can try to delete and re build the class. I also want to note that the API versions are all 55.0 and they are all listed as active so nothing funny going on there.
    – Olivia
    Oct 21, 2022 at 17:04
0

I found out the issue was with a Gearset setting.

Once we updated the setting the class and trigger were deployed fine.

1
  • be useful to document what setting you changed/aded
    – cropredy
    Nov 5, 2022 at 0:44

You must log in to answer this question.

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