[SalesForce] Dreaded “Method does not exist or incorrect signature” Error when executing

Here is the full Error message:

Method does not exist or incorrect signature:Line: 1, Column: 1 Method
does not exist or incorrect signature:
CompareNewAndOldFiscalPeriod.compareMonths(Integer, Integer)

When trying to execute the code below:

More generally does anyone have a guide on how to trouble shoot this error. It crops up a lot and seems to have completely different causes in every case.

Execute Anonymous:

CompareNewAndOldFiscalPeriod.compareMonths(11/1/2015,1/1/2016);

Class

public class CompareNewAndOldFiscalPeriod {

//Set  up to see if the change in and end date results is moving the opportunity to a different fiscal month.  This is used as a measure of pipeline quality
//Designed to be called by a flow that is evaluating other changes in oppty data.

//find fiscal month of old close date
public static Boolean compareMonths(date OldClose, date NewClose){
    List<Period> OldPeriod= [SELECT Number,Id From Period WHERE type = 'Month' AND StartDate < =:OldClose AND EndDate>=:OldClose LIMIT 1];
    period Per=New period();
    Integer OldMonth=0;
    Per=OldPeriod.get(0);
    OldMonth=per.Number;  


    //find fiscal month of new close date  
    List<period> NewPeriod=[SELECT Number,Id From Period WHERE type = 'Month' AND StartDate < =:NewClose AND EndDate>=:NewClose LIMIT 1];
    period Per2=New period();
    Integer NewMonth=0;
    Per2=NewPeriod.get(0);
    NewMonth=per2.Number;   

    system.debug('New fiscal month is' + NewMonth);

    //compare and return a verdict about whether or not this will count as a change in Fiscal Period
    Boolean verdict=false;
    If(NewMonth>OldMonth){
        verdict=true;

        System.debug('Verdict is '+ verdict);
    }
  return verdict;
}

}

Best Answer

You will call your method in following format.

Date startDate = date.parse('11/1/2015');
Date endDate = date.parse('1/1/2016');
compareNewAndOldFiscalPeriod.compareMonths(startDate,endDate); 
Related Topic