function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bharathsdsd kumarbharathsdsd kumar 

Attempt to deference a null object error

Hi,

I have a following method where i am getting

System.null pointer exception : attempt to dereference a null object


Kindly help me how to fix it

This is my method where error occurs
METHOD :

public void CallPremisysQuote(Team_Form__c so)
			{ 
				
				list<Team_Form__c>lstTF = [select ID,Engagement_Script__r.GPS_VRD_Customer__c from Team_Form__c where Id = :so.Id];
				if(TFIdPSQuoteMap.get(so.Id)!= null && TFIdPSQuoteMap.get(so.Id).size()>0)
				{
					PremisysQuoteExist= True;      
				}
				
				if(so.Status__c=='Released to Sales')
				{
					
					if(!PremisysQuoteExist)
					{
						if(lstTF[0].Engagement_Script__r.GPS_VRD_Customer__c.touppercase() == 'NO'){
							
							if(so.PS_Engagement_Type__c=='New Order')
							{ 
								
								GPS_Premisys_CreateQuote.fnCreatePremisysQuote(so.Id);
							}
							
							else
							{
								if(so.GPS_Price_Impacting__c=='Yes')
								{
									
									GPS_Premisys_CreateQuote.fnCreatePremisysQuote(so.Id);                 
								}              
								
							}
						}
                /*else{
so.addError('PremiSys quote cannot be created for VRD customers. The sales team has chosen this option on the Engagement Script');        
}*/
            }      
        }

Kindly help me pls

Thanks in Advance
EldonEldon
In which line are you getting that error?
 
bharathsdsd kumarbharathsdsd kumar
Line no 15

                    if(!PremisysQuoteExist)
bharathsdsd kumarbharathsdsd kumar
do i need to do a null check for t he list that i have declared ?
EldonEldon
What is this PremisysQuoteExist? is it a boolean
Brice VEZINBrice VEZIN
PremisysQuoteExist must be initialized with a value (true or false) before calling your method our in you method. If not and if your first condition is wrong, PremisysQuoteExist is null.
Muzammil BajariaMuzammil Bajaria
You should try initializing the boolean variable...