function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jay IiladharJay Iiladhar 

Apex trigger issue

I am recieving the following error when saving a lead record - Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger Lead caused an unexpected exception, contact your administrator: Lead: execution of BeforeInsert caused by: line 7, column 4: trigger body is invalid and failed recompilation: Method does not exist or incorrect signature: LeadTriggerHandler.TriggerBeforeInsert(List)

I cant seem to find the source of the issue - any ideas?
Best Answer chosen by Jay Iiladhar
William LópezWilliam López
Hello Jay,

Ok so I far I can see. You have a class that will be call from the trigger. But right now the class its commeted out.

You need to uncomment your "LeadTriggerHandler" class and so the trigger can see the method "TriggerBeforeInsert".

1) Trigger named lead should have a line like this:

User-added image

2) The class LeadTriggerHandler should a method call TriggerBeforeInsert, that right not its commented, just remove the comments "//" save the class and then save the trigger and it should work.

User-added image

I will suggest to start by removing the comments form the methods defintion, so at least the trigger will be able to complie, then you can comple you work in the class.

Lest me know how it goes.

Regards,

Bill
 

All Answers

William LópezWilliam López
Hello Jay.

Can you plese share the code ? Seems to be an issue in the line 7, either the method does no exist or there is an issue with the parameters of that method. If you share the code I might be able to help you.
Jay IiladharJay Iiladhar
HI thanks for replying, heres the code (ive tried to change it so it doesnt execute it however this did not work.

public class LeadTriggerHandler 
{   
    //public static void TriggerBeforeInsert (List<Lead> lLeads)
    {
        //List<Lead> lPostalSectorsToInsert = new List<Lead>();
        
        //for (Lead lead : lLeads)
        {
  //          if (lead.Country == 'UK' || lead.Country =='CA')
            {
   //             lPostalSectorsToInsert.add(lead);
            }
        }
        
   //     if (lPostalSectorsToInsert.size() > 0)
        {
   //         LeadUtil.assignPostalSector(lPostalSectorsToInsert);    
        }   
    }
    
   // public static void TriggerBeforeUpdate (List<Lead> lNewLeads, Map<Id, Lead> mapOldLeads)
    {
   //     List<Lead> lPostalSectorsToUpdate = new List<Lead>();
        
   //     for (Lead lead : lNewLeads)
        {
   //         if (((lead.Country == 'UK' || lead.Country =='CA') && !lead.PostalCode.equals(mapOldLeads.get(lead.Id).PostalCode)) || ((lead.Country == 'UK' || lead.Country =='CA') && lead.PostalCode.equals(mapOldLeads.get(lead.Id).PostalCode)))
            {
   //             lPostalSectorsToUpdate.add(lead);
            }
   //         else if (lead.Country!=mapOldLeads.get(lead.id).Country
   //         && (lead.Country != 'UK' || lead.Country !='CA'))
            {
   //             lead.Territory_Postal_Sector__c = null;
            }
        }
        
   //     if (lPostalSectorsToUpdate.size() > 0)
        {
   //         LeadUtil.assignPostalSector(lPostalSectorsToUpdate);    
        }   
    }
}
William LópezWilliam López
Hello Jay,

Ok so I far I can see. You have a class that will be call from the trigger. But right now the class its commeted out.

You need to uncomment your "LeadTriggerHandler" class and so the trigger can see the method "TriggerBeforeInsert".

1) Trigger named lead should have a line like this:

User-added image

2) The class LeadTriggerHandler should a method call TriggerBeforeInsert, that right not its commented, just remove the comments "//" save the class and then save the trigger and it should work.

User-added image

I will suggest to start by removing the comments form the methods defintion, so at least the trigger will be able to complie, then you can comple you work in the class.

Lest me know how it goes.

Regards,

Bill
 
This was selected as the best answer
Jay IiladharJay Iiladhar
Thanks Bill seems to have worked. I was wondering if you can halp me with a further issue? Its regarding Territoris V2 
William LópezWilliam López
Jay glad to hear it worked.

Sure I can try to help you with that. But I am sure people in the community will be also glad to help, therefore I suggest you to create a new post with details about what you want to accomplish, what issues are you having, code and structure you have so far. 

Regards,
Bill