You need to sign in to do that
Don't have an account?
Constructor not defined, confused!@#$%
Hi folks i have this code that's supposed to be generating some data to be passed to visual force charts. i get this error....
Error: Compile Error: Constructor not defined: [PropertyInquiryReports.InqsClass].<Constructor>(Integer, Integer) at line 51 column 29
any insights? thanks you.
public class PropertyInquiryReports {
public List<AggregateResult> inqs = new List<AggregateResult>();
public PropertyInquiryReports()
{
String Property_Name = Apexpages.CurrentPage().getParameters().get('Property_Name');
String dfm = Apexpages.CurrentPage().getParameters().get('dfm');
String dfy = Apexpages.CurrentPage().getParameters().get('dfy');
String dtm = Apexpages.CurrentPage().getParameters().get('dtm');
String dty = Apexpages.CurrentPage().getParameters().get('dty');
Integer dfmC = integer.valueof(dfm);
Integer dfyC = integer.valueof(dfy);
Integer dtmC = integer.valueof(dtm);
Integer dtyC = integer.valueof(dty);
Date FromDate = date.newinstance(dfyC, dfmC, 1);
Date ToDate = date.newinstance(dtyC, dtmC, 31);
AggregateResult[] inqs =
[SELECT
COUNT(Id) theCount,
SUM(Reporting_Is_Converted_to_Booking__c) theCountConvertedBooking,
CALENDAR_YEAR(CreatedDate) theYear,
CALENDAR_MONTH(CreatedDate) theMonth
FROM Inquiry__c
WHERE Property__r.Name = :Property_Name AND
CreatedDate >: FromDate AND CreatedDate <: ToDate
GROUP BY CALENDAR_Year(CreatedDate) , CALENDAR_MONTH(CreatedDate)
ORDER BY CALENDAR_Year(CreatedDate), CALENDAR_MONTH(CreatedDate) ASC ];
}
public list<InqsClass> getResults()
{
list<InqsClass> InqsCounts = new list<InqsClass>();
for (AggregateResult ar: inqs)
{
Integer the_count = Integer.valueOf(ar.get('theCount'));
Integer the_count_converted_booking = Integer.valueOf(ar.get('theCountConvertedBooking'));
String the_month_and_year = Integer.valueOf(ar.get('theYear')) + '-' + Integer.valueOf(ar.get('theMonth));
InqsCounts.add(new InqsClass(the_count, the_count_converted_booking, the_month_and_year));
}
return InqsCounts;
}
class InqsClass
{
public Integer the_count {get; set;}
public Integer the_count_converted_booking {get; set;}
public String the_month_and_year {get; set;}
public InqsClass(AggregateResult ar)
{
the_count = (integer)ar.get('theCount');
the_count_converted_booking = (integer)ar.get('theCountConvertedBooking');
the_month_and_year = (string)ar.get('the_month_and_year');
}
}
}
In the following line:
your code is assuming there is a constructor for the InqsClass that takes 3 parameters - two integers and a string. However, the class only has a constructor that takes a single aggregateresult parameter:
It looks to me like you should be carrying out the processing in getResults that creates the new InqsClass objects in the constructor itself - you almost are, its just that the year and month are handled slightly differently.
All Answers
In the following line:
your code is assuming there is a constructor for the InqsClass that takes 3 parameters - two integers and a string. However, the class only has a constructor that takes a single aggregateresult parameter:
It looks to me like you should be carrying out the processing in getResults that creates the new InqsClass objects in the constructor itself - you almost are, its just that the year and month are handled slightly differently.
In your "InqsClass" class this constructor InqsClass(the_count, the_count_converted_booking, the_month_and_year) is not defined.
Regards,
i'm new to salesforce and apex, relatively anyway, and i'd be up a creek without the people on this forum.