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

null point error
the highlighted line in blod says null point excemption any idea?
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);
}
}
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);
}
}
Your code is fine. Maybe you are getting this error because you would not have been pass the parameter properly in getEndOfCurrentTerm method.
You can take reference from this below code and pass the parameter in method like this:- In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Hi,
Please find the solution.
I think there is no data inside termStartDate that's why you are not able to add 1 year to it.
Just debug termStartDate. i.e System.debug(termStartDate);
or
Date datobj;
Integer dy = termStartDate.day();
Integer mon = termStartDate.month();
Integer yr = termStartDate.year();
integer year =yr+1;
String termsDate=dy+'/'+mon+'/'+yr;
Please mark is as the Best Answer if it helps You
Thank You
is data coming in termStartDate after debugging??
try following code and check still you are facing the same error?
let me know if it helps you and mark it as best answer.
Thank you