0

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;
}

}
  • from where you are calling this method ? As per the error message you are passing integer but this method accept date as data type. – Himanshu Mar 12 '16 at 20:01
  • Execute Anonymous: CompareNewAndOldFiscalPeriod.compareMonths(11/1/2015,1/1/2016); – Thaddeus Ward Mar 12 '16 at 20:06
1

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); 
1

Your signature takes (Date, Date) but you are passing (Integer, Integer).

Integer a = 1/1/2015;
Integer b = 1/1/2016;
myMethod(a, b); // incorrect

Date x = Date.newInstance(2015, 1, 1);
Date y = Date.newInstance(2016, 1, 1);
myMethod(x, y); // correct

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.