I am currently trying to get this trigger to work:

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

That is using the following Class:

public class ContactRelatedOppsClass {
    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];

                // dernière demande gagnée   
                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;

But keep getting the error message "Method does not exist or incorrect signature: void OpportunitiesUpdates(List) from the type ContactRelatedOppsClass"

Please need help ! Thank you !

1 Answer 1


Your method takes a List<ID>, but you're passing a List<Opportunity> These types are distinct and not interchangeable.

As a part of fixing this, though, your class needs to be bulkified. Currently, you are operating on only a single Opportunity, and your class will throw a QueryException if more than one Opportunity Id is passed from the trigger. You need to query into collections and operate upon those.

Once you bulkify your class, you'll likely want to change the parameter type to Set<Id>, and pass from the trigger Trigger.newMap.keySet().

  • Thank you for your response ! I understand the List<ID> and List<Opportunity> issue. But how can I bulkify the queries ? It is my first time, so I am also wondering if I can directfly bulkify my trigger maybe ? Doesn't the @future allow the class to process batches? Thank you very much for your response ! Commented Apr 20, 2020 at 7:52
  • There is a very good unit on Trailhead that goes over bulkification patterns: Bulk Apex Triggers. Highly recommend it. @future and batch Apex are very different.
    – David Reed
    Commented Apr 20, 2020 at 15:21

You must log in to answer this question.

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