+ Start a Discussion
ShreyankaShreyanka 

How to fix Error: "Method does not exist or incorrect signature"

Hi everyone,
I am getting error "Method does not exist or incorrect signature: void method3(List<opportunity>) from the type SampleTriggerHandler" on SampleTrigger class.

Please help me to fix this error.

Thanks in advance!
 
Trigger Code:

trigger SampleTrigger on Abc (before insert,before update, after undelete, after insert, after update) {
    
    if( trigger.isInsert && trigger.isBefore) 
    {
		SampleTriggerHandler.method1(trigger.new,Trigger.oldMap);
    }
    if( (trigger.isUpdate && trigger.isBefore) ||  (trigger.isundelete))
    {
        
        SampleTriggerHandler.method1(trigger.new,Trigger.oldMap);
    }
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)) 
	{
        SampleTriggerHandler.method2(Trigger.new, Trigger.oldMap);
    }
    
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate ))
    {
		SampleTriggerHandler.method3(trigger.new);
    }
    
}
 
TriggerHandler Code:


public class SampleTriggerHandler {

public static void method1
{
//code block
}

public static void method2
{
//code block
}

    
public static void method3 (List<opportunity> opp)
{
set<id> oppid = new set<id>();

List<opportunity> oppList = [select id, opp_name, from Opportunity where id=:oppid];

List<opportunity> updateList = new List<opportunity>();

Map<Id, opportunity> oppMap= new Map<id,opportunity>();

for(opportunity opp1: oppList) {

}
}
}

 
AnkaiahAnkaiah (Salesforce Developers) 
Hi Shreyanka,

You need to pass argements to the respective methods.

You need to modify your apex class as like below.
public class SampleTriggerHandler {

public static void method1(List<opportunity> opp,Map<id,opportunity> oldopp)
{
//code block
}

public static void method2(List<opportunity> opp,Map<id,opportunity> oldopp)
{
//code block
}

    
public static void method3 (List<opportunity> opp)
{
set<id> oppid = new set<id>();

List<opportunity> oppList = [select id, Name from Opportunity where id=:oppid];

List<opportunity> updateList = new List<opportunity>();

Map<Id, opportunity> oppMap= new Map<id,opportunity>();

for(opportunity opp1: oppList) {

}
}
}

If this helps, Please mark it as best answer.

Thanks!!
mukesh guptamukesh gupta
Hi Shreyanka,

Please use below code:-
 
trigger SampleTrigger on Opportunity (before insert,before update, after undelete, after insert, after update) {
    
    if( trigger.isInsert && trigger.isBefore) 
    {
		SampleTriggerHandler.method1(trigger.new);
    }
    if( (trigger.isUpdate && trigger.isBefore) ||  (trigger.isundelete))
    {
        SampleTriggerHandler.method2(trigger.new,Trigger.oldMap);
    }
    if(Trigger.isAfter && (Trigger.isUpdate || Trigger.isUndelete)) 
	{
        SampleTriggerHandler.method3(Trigger.new, Trigger.oldMap);
    }
	if(Trigger.isAfter && Trigger.isInsert) 
	{
        SampleTriggerHandler.method4(Trigger.new);
    }
    
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate ))
    {
		SampleTriggerHandler.method5(trigger.new,Trigger.oldMap);
    }
 }
 
public class SampleTriggerHandler {

public static void method1(List<Opportunity> oppList)
{
//code block
}

public static void method2(List<Opportunity> oppList, Map<Id,Opportunity> oldOppMap)
{
//code block
}

public static void method3 (List<Opportunity> oppList, Map<Id,Opportunity> oldOppMap)
{
set<id> oppid = new set<id>();

List<opportunity> oppList = [select id, opp_name, from Opportunity where id=:oppid];

List<opportunity> updateList = new List<opportunity>();

Map<Id, opportunity> oppMap= new Map<id,opportunity>();

for(opportunity opp1: oppList) {

}
}

public static void method4(List<Opportunity> oppList)
{
//code block
}

public static void method5(List<Opportunity> oppList, Map<Id,Opportunity> oldOppMap)
{
//code block
}

    

}

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh