calling my apex method in apex trigger getting the error

1k Views Asked by At
    public static void insertInboundJive(Map<Id, String> mapCases){
    try{

        system.debug('Aditya');
        Map<Id, String> mapCases1 = new Map<Id, String>();
        Map<Id, Integer> mapIncrements = new Map<Id, Integer>();
        //List<ICS_Case_Interaction__c> lstCaseInteraction;
        if(mapCases != null && mapCases.size() > 0) {
        List<ICS_Case_Interaction__c> lstCaseInteraction  = [ SELECT Id,case__r.origin FROM ICS_Case_Interaction__c Where case__r.Id =:mapCases.keySet()];
            for(ICS_Case_Interaction__c caseInteracts :lstCaseInteraction ){
                if(caseInteracts.case__r.Id != null && caseInteracts.case__r.Status == 'New Customer Message'){
                    system.debug('**AdityaDebug**' +caseInteracts.case__r.Id);
                    system.debug('**AdityaDebug**' +caseInteracts.case__r.Status);
                    mapcases1.put(caseInteracts.case__r.Id , TYPE_JIVE_INBOUND);
                    Integer intIncrement = mapIncrements.get(caseInteracts.case__r.Id);
                    system.debug('Increment' +intIncrement);
                    if(intIncrement != null){
                        intIncrement++;
                        system.debug('Increment++' +intIncrement);
                    }
                    else {
                        intIncrement = 1;
                    }
                     mapIncrements.put(caseInteracts.case__r.Id, intIncrement);
                }
            }
            if(mapCases.size() > 0) {
                insertByCaseAsync(mapCases, mapIncrements);
            }
        }
    }
    catch(Exception ex){
        Core_Log_Entry.logEntryWithException('Case Interaction Metrics', 'CaseInteraction','insertInboundEmail', 'Error', null, null, ex);
    }

}

This is my Method in the class.I am trying to call the apex method in the trigger.but its throwing the error.Could you please help me and try to reach out the best.

The error which I am getting was line 188, col 106. Method does not exist or incorrect signature: void insertInboundJive(List) from the type ICS_Case_Interactions_Trigger_Handler

if(trigger.isUpdate) {

if(Label.ICS_Case_Interaction_Metrics.equals('1')) {ICS_Case_Interactions_Trigger_Handler.insertInboundJive(trigger.new);} }

1

There are 1 best solutions below

0
On

You are trying to pass the wrong parameters. In the method you have defined that when called you need to pass a Map where the values are String however you are passing Trigger.new which is a list of Objects. My approach is to handle the mapping in the trigger and then manipulate data in the controller:

In this case you can do the below to pass the records and get the string of data you want in the controller.. or do it in the trigger so you don't change the controller.

Map<Id,Contact> map = new Map<Id,ICS_Case_Interaction__c>();  // new map

for(ICS_Case_Interaction__c con :trigger.new){  
    map.put(con.Id, con);  // enter the records you need for the method
}

if(trigger.isUpdate) {
        if(Label.ICS_Case_Interaction_Metrics.equals('1')) {
    ICS_Case_Interactions_Trigger_Handler.insertInboundJive(map);
        } 
    }

and in the controller you should have

public static void insertInboundJive(Map<Id, ICS_Case_Interaction__c> mapCases){
}