1

I'm running into the following error and not able to get around it. I've looked at a few other posts to help, including make the method static (which it is) and call the method in a different way (tried it), but neither worked.

Any ideas?

Save error: Method does not exist or incorrect signature: pipelineRepContactUpdateClass.myMethod(Set, Map)

Trigger:

trigger pipelineRepContactUpdate on Account (after update) {
    Set<Id> lst_acc_id = new Set<Id>();//Store the sets of Impacted Account for which you have changed the field value
    Map<Id,Id> map_accounId_OwnerId = new Map<Id,Id>();//map of account Id and OwnerId
    List<Contact> lst_updated_contact = new List<Contact>();//List of updated contact

    if(Trigger.isAfter && Trigger.isUpdate){ 
        for(Account  acc : Trigger.New){ 
            //Checks whether the value changes from previous one or not
            if((Trigger.oldMap.get(acc.Id).Pipeline_Rep__c != Trigger.newMap.get(acc.Id).Pipeline_Rep__c) &&  Trigger.newMap.get(acc.Id).Pipeline_Rep__c!=null){
                lst_acc_id.add(acc.Id); 
                map_accounId_OwnerId.put(acc.Id,acc.Pipeline_Rep__c);//preparing the map
            }
        }    
    }

    if(lst_acc_id.size()>0){
        // call class here (lst_acc_id,map_accounId_OwnerId)
        pipelineRepContactUpdateClass.myMethod(lst_acc_id,map_accounId_OwnerId);
    }

}

Class:

public class pipelineRepContactUpdateClass {

    @future 
    public static void myMethod(List<Id> lst_acc_id, Map<Id,Id> map_accounId_OwnerId){

        List<Contact> lst_updated_contact = new List<Contact>();//List of updated contact

        if(lst_acc_id.size()>0){
            //query all the contact related to the Account
            List<Contact> lst_con = [Select Id,OwnerId,AccountId from Contact where AccountId IN : lst_acc_id];   
            if(lst_con.size()>0){
                for(Contact con : lst_con){
                    con.OwnerId = map_accounId_OwnerId.get(con.AccountId);// assigning the Account Pipeline_Rep__c field

                    lst_updated_contact.add(con);
                }
            }
        }

        if(lst_updated_contact.size()>0){
            update  lst_updated_contact;//update the contact records
        }   

    }   

}

1 Answer 1

2

Your signature accepts List, and you are trying to pass Set.

Change:

Set<Id> lst_acc_id = new Set<Id>();

to:

List<Id> lst_acc_id = new List<Id>();

Or you can change the signature from:

public static void myMethod(List<Id> lst_acc_id, Map<Id,Id> map_accounId_OwnerId)

to:

public static void myMethod(Set<Id> lst_acc_id, Map<Id,Id> map_accounId_OwnerId)

Also a word on naming. I find that in general, your code will be much more reading if you entirely avoid specifying the collection type in the name (as here you have actually called it a List even though it is not). Also, you should indicate it is a collection simply by making it plural. A much better variable name here would be accountIds.

You must log in to answer this question.

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