0

I am having a class which has future annotation and I am calling that apex class through a trigger then trigger is giving me below error.

"Method does not exist or incorrect signature: void relatedtows(Id) from the type RelatedTowtoContact"

My Class:

public class RelatedTowtoContact {
@future(callout =true)
public static void relatedtows(List<Id> alltows123){
    List<Related_TOW__c> allrelatedtows = [select Id, Name, Lead__c, Contact__c,Tow_Id__c from Related_TOW__c where Id IN: alltows123];
    set<Id> contactid = new set<Id>();
    set<Id> leadId = new set<Id>();
    for(Related_TOW__c tow: allrelatedtows){
        //------------------------------------------//
        if(tow.Lead__c != NULL){
        //if(tow.Contact__c != null){
            leadId.add(tow.Lead__c);
        //}
    //}
    system.debug('contactId is :' + contactid);
    Map<Id, Lead> leadMap = new Map<Id,Lead>([select Id, Related_TOW_IDs__c from Lead where Id IN : leadId]);
    List<Lead> updatelead = new List<Lead>();
    system.debug('leadMap is :' + leadMap);
    for(Related_TOW__c t : allrelatedtows){
        if(leadMap.get(t.Lead__c).Related_TOW_IDs__c == null){
            leadMap.get(t.Lead__c).Related_TOW_IDs__c = t.Tow_Id__c;
            system.debug('related tow is : ' + leadMap.get(t.Lead__c).Related_TOW_IDs__c);
        }
        else{
            leadMap.get(t.Lead__c).Related_TOW_IDs__c = leadMap.get(t.Lead__c).Related_TOW_IDs__c + ';' + t.Tow_Id__c;
        }
       // updatecon.add(conMap);
    }
    update leadMap.values();
        }

Trigger:

trigger TowIdtoContact on Related_TOW__c (After insert, After Update) {
for(Related_TOW__c tow: trigger.new){
    RelatedTowtoContact.relatedtows(tow.Id);
}

}
1

You are passing an Id as a parameter to your apex class method where it accepts a list. Do following it will resolve the issue.

trigger TowIdtoContact on Related_TOW__c (After insert, After Update) {
   for(Related_TOW__c tow: trigger.new){
       RelatedTowtoContact.relatedtows(new List<Id>{tow.Id});
   }
}
2
  • I updated the code but still getting the same issue again
    – prakash
    Mar 10 '20 at 9:12
  • Is your apex class saved and there are no errors. Some time there are errors due to which latest changes are not saved. Mar 10 '20 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.