You need to sign in to do that
Don't have an account?

null point
the bold line null point it seems the value is null , what is termstartdate here pls suggest me
public static Date getEndOfCurrentTerm(
Date termStartDate,
Date effectiveDate,
Integer initialTerm) {
List<Date> terms = new List<Date>();
Integer numberOfTerms = initialTerm / 12;
// make the terms list based on the initialTerm
for (Integer i = 1; i <= numberOfTerms + 1; i++) {
terms.add(termStartDate);
termStartDate = termStartDate.addYears(1); // this give null point error
}
public static Date getEndOfCurrentTerm(
Date termStartDate,
Date effectiveDate,
Integer initialTerm) {
List<Date> terms = new List<Date>();
Integer numberOfTerms = initialTerm / 12;
// make the terms list based on the initialTerm
for (Integer i = 1; i <= numberOfTerms + 1; i++) {
terms.add(termStartDate);
termStartDate = termStartDate.addYears(1); // this give null point error
}
seems like termStartDate has null value, can you check termStartDate has value before entering for loop, because null pointer error happens when we try to do any fucntion on null vale.
Thanks
Surya G
here what is the field in termstart date in the loop.
termStartDate is date value which you are passing when you are calling this method
getEndOfCurrentTerm(Date termStartDate, Date effectiveDate, Integer initialTerm)
post the full code where you are calling this method, we can see where it is going wrong
private static void getDates(String quoteId, CVData data) {
zqu__Quote__c quote = getQuote(quoteId);
data.quote = quote;
data.changeEffectiveDate = quote.zqu__StartDate__c;
data.subscriptionTermStartDate = quote.zqu__SubscriptionTermStartDate__c;
// end of current term
data.endOfCurrentTerm = getEndOfCurrentTerm(
quote.zqu__SubscriptionTermStartDate__c,
quote.zqu__StartDate__c,
(Integer) quote.zqu__InitialTerm__c
);
public static Date getEndOfCurrentTerm(
Date termStartDate,
Date effectiveDate,
Integer initialTerm) {
List<Date> terms = new List<Date>();
Integer numberOfTerms = initialTerm / 12;
// make the terms list based on the initialTerm
for (Integer i = 1; i <= numberOfTerms + 1; i++) {
terms.add(termStartDate);
termStartDate = termStartDate.addYears(1); // here it shows error
}
System.debug(LoggingLevel.INFO, 'terms: ' + terms);
System.debug(LoggingLevel.INFO, 'EffectiveDate: ' + effectiveDate);
// check if the effective date is less than each term start date
for (Integer i = 0; i < terms.size(); i++) {
if (effectiveDate <= terms[i]) {
return terms[i].addDays(-1);
}
}