I've got some simple code and I'm wondering if someone can help me understand why it would result in the "Attempt to de-reference a null object" error? This is part of a custom controller that I'm using for a Visualforce page. Please let me know if I can provide any additional info for clarity. Thank you!
public with sharing class NewBusinessForecastingController {
private ApexPages.StandardController controller {get; set;}
public List<SBQQ__Quote__c> q {get; set;}
public List<SBQQ__Quote__c> clonedQuoteList {get; set;}
public NewBusinessForecastingController(ApexPages.standardController std) {
q = [
SELECT
SBQQ__Opportunity2__r.Quarter_View__c,
SBQQ__Opportunity2__r.Account.Name,
SBQQ__Opportunity2__r.CloseDate,
SBQQ__Opportunity2__r.Name,
SBQQ__Opportunity2__r.Id,
Quote_Name__c,
Name,
Id,
(SELECT
SBQQ__SubscriptionTerm__c,
Delivery_Start_Date__c,
Delivery_Frequency__c,
SBQQ__Product__r.Name,
Delivery_End_Date__c,
Line_Description__c,
Data_Start_Date__c,
Data_End_Date__c,
Name,
Id
FROM SBQQ__LineItems__r)
FROM SBQQ__Quote__c
WHERE SBQQ__Opportunity2__r.OwnerId = :UserInfo.getUserId() AND
SBQQ__Opportunity2__r.Probability > 0 AND
SBQQ__Opportunity2__r.Probability < 96 AND
SBQQ__Primary__c = TRUE AND
Id IN (SELECT SBQQ__Quote__c FROM SBQQ__QuoteLine__c)
ORDER BY SBQQ__Opportunity2__r.CloseDate
];
for(SBQQ__Quote__c cloneQuote : q) {
SBQQ__Quote__c clonedQuote = cloneQuote.clone();
clonedQuoteList.add(clonedQuote);
}
}
If I comment out the line that adds each record to the list, I don't encounter the error. The line below is line 41, which is where the fatal error is encountered.
clonedQuoteList.add(clonedQuote);