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
Frédéric RonteixFrédéric Ronteix 

Having trouble with Class used in a Trigger! Getting " Method does not exist or incorrect signature"

Dear all ! 

I have troube with my trigger and keep getting "Method does not exist or incorrect signature" . What can I do ?

trigger ContactRelatedOpportunities on Opportunity (after insert, after update) {
     List<Opportunity> Opps = [SELECT Id FROM Opportunity WHERE Opportunity.Id IN :Trigger.New];
        ContactRelatedOppsClass.OpportunitiesUpdates(Opps);  
}

using the following class: 

public class ContactRelatedOppsClass {
    @future
    Public static void OpportunitiesUpdates (List<ID> Opps){
        for (ID a:Opps){
            Opportunity OpportuniteAnalysee = [SELECT ID, Name, iCom_QTC__Contact__c FROM Opportunity WHERE ID =:a];
                Contact ContactAssocie  = [SELECT Id,LatestWonOpp__c,LatestLostOpp__c,NextWonOpp__c,NextOpp__c FROM Contact WHERE Id =:OpportuniteAnalysee.iCom_QTC__Contact__c];
                System.debug(ContactAssocie);
                  
                List <Opportunity> latestWonOpp = [SELECT Id
                                                              FROM Opportunity 
                                                              WHERE (iCom_QTC__Contact__c = :ContactAssocie.ID AND StageName='Demande gagnée' AND Nombre_de_jours_relatif_event__c >= 0) 
                                                              ORDER BY Nombre_de_jours_relatif_event__c 
                                                              LIMIT 1];
                if(latestWonOpp != null && !latestWonOpp.isEmpty()){
                    ContactAssocie.LatestWonOpp__c = latestWonOpp[0].Id;
                } else {
                    ContactAssocie.LatestWonOpp__c = null;
                }
                update ContactAssocie
}}}
AbhishekAbhishek (Salesforce Developers) 
Hi,

You can try the suggestion as mentioned in the below blog,

https://developer.salesforce.com/forums/?id=906F00000008uiBIAQ

https://salesforce.stackexchange.com/questions/12358/method-does-not-exist-or-incorrect-signature

https://stackoverflow.com/questions/16741267/apex-coding-error-method-does-not-exist-or-incorrect-signature

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

Thanks.
David Zhu 🔥David Zhu 🔥
Hi there, 

OpportunitiesUpdates (List<ID> Opps)  - has parameter List<ID>.

You pass List<Opportunit> in your trigger.
List<Opportunity> Opps = [select .....];
 ContactRelatedOppsClass.OpportunitiesUpdates(Opps); 

Change your trigger:
 ContactRelatedOppsClass.OpportunitiesUpdates(Trigger.newMap.keySet());