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
Fe PradellaFe Pradella 

Method does not exist or incorrect signature during trigger

Hi there, I've created a public class called RltdEnergyAudits that has a public method ExibirRelatedAudits. Looks like this:
 
public class RltdEnergyAudits 
{
    
    public static void ExibirRelatedAudits(List<Energy_Audit__c> Accounts)
    {
        system.debug('Exibir Audits');
    }

}


The class compiles with no errors. When I try to compile a trigger that has a call to the ExibirRelatedAudits method, I get the message "method does not exist or incorrect signature" on the line that calls the method. The trigger looks like this:
 
trigger AccountUpdate on Account (before update) 
{
    if(Trigger.isUpdate)
    {
        List<Account> listaAccounts = [SELECT ID from Account where Id in :Trigger.new];
        RltdEnergyAudits xx = new RltdEnergyAudits();
        xx.ExibirRelatedAudits(listaAccounts);
    }

}

I got error: Method does not exist or incorrect signature: void ExibirRelatedAudits(List<Account>) from the type RltdEnergyAudits

I tried also code bellow but same error:  

Method does not exist or incorrect signature: void ExibirRelatedAudits(List<Account>) from the type RltdEnergyAudits

trigger AccountUpdate on Account (before update) 
{
    if(Trigger.isUpdate)
    {
        List<Account> listaAccounts = [SELECT ID from Account where Id in :Trigger.new];
        RltdEnergyAudits.ExibirRelatedAudits(listaAccounts);
    }

}
Any guidance would be most appreciated. Thank you!
 
Sathish LoganathanSathish Loganathan
Hi,

It looks like you are trying to pass List of standard object Accounts to the class which can accept only Energy_Audit__c.If you fix the trigger to pass the ids related to Energy_Audit__c, you will not see this error.
Ajay K DubediAjay K Dubedi
Hi Fernanda,
In your classRltdEnergyAudits, In ExibirRelatedAudits method you take Energy_Audit__c type of list and in your trigger, you pass Account type object as listaAccounts, so please change List<Energy_Audit__c> Accounts to List<Account> Accounts like:
public class RltdEnergyAudits 
{
    
    public static void ExibirRelatedAudits(List<Account> Accounts)
    {
        system.debug('Exibir Audits');
    }
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Deepali KulshresthaDeepali Kulshrestha
Hi Fernanda,

- In your code, you have returned the list of Energy_Audit__c object but Trigger.new returns the list of the object on which you have written your trigger and your trigger is on Account so it will return the list of Account. 
- I implemented it in my Org and code is running fine. Please use the below code  : 
---------------Trigger-------------------------

   trigger AccountUpdate on Account (before update) 
{
    if(Trigger.isUpdate)
  
        RltdEnergyAudits.ExibirRelatedAudits(Trigger.new);
    }

}
---------------Helper Class-------------------------

 public class RltdEnergyAudits 
{
    
    public static void ExibirRelatedAudits(List<Account> Accounts)
    {
        system.debug('Exibir Audits');
    }

}
    
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.