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

System.NullPointerException: Attempt to De-Reference a Null Object

All I am getting the above Error when trying to insert records from an integration.


Here iso the code it is erroring on: IT is erroring on the live that begins: List<Patient_Data__c> objPatient

global class wsLoad_NDD_Data {

Value, Trial, Trial Data, Result Parameters)
	global class PatientData{
		WebService String strPatientId;
		WebService String strFirstName;
		WebService String strLastName;
		WebService String strIsBioCal;
		WebService String strEthnicity;
		WebService String strAsthma;
		WebService String strGender;
		WebService Date dtmDateOfBirth;
		WebService String strCOPD;
		WebService Decimal numHeight;
		WebService Decimal numWeight;
		WebService String strSite;
		WebService String strSmoker;
	webservice static Patient_Data__c LoadPatientData(PatientData PDInfo)
		 Patient_Data__c insertPatientData = null;
         // Look for the Patient_Data_ID__c being passed in.
         List<Patient_Data__c> objPatient = [SELECT Patient_ID__c FROM Patient_Data__c WHERE Patient_ID__c = :PDInfo.strPatientId];
         if(objPatient.size() > 0)
        	//Existing Patient Check
        	List<Patient_Data__c> updatePatientData = [SELECT First_Name__c, Last_Name__c, IsBioCal__c, Ethnicity__c, Asthma__c, Gender__c, Date_of_Birth__c, COPD__c, Height__c, Weight__c  FROM Patient_Data__c
            WHERE Patient_ID__c = :PDInfo.strPatientId];
            for (Patient_Data__c pd : updatePatientData)
            pd.First_Name__c = PDInfo.strFirstName;
            pd.Last_Name__c = PDInfo.strLastName;
            pd.IsBioCal_Int__c = PDInfo.strIsBioCal;
            pd.Ethnicity__c = PDInfo.strEthnicity;
            pd.Asthma__c = PDInfo.strAsthma;
            pd.Gender__c = PDInfo.strGender;
            pd.Date_of_Birth__c = PDInfo.dtmDateOfBirth;
            pd.COPD__c = PDInfo.strCOPD;
            pd.Height__c = PDInfo.numHeight;
            pd.Weight__c = PDInfo.numWeight; 
            pd.Site__c = PDInfo.strsite; 
        update updatePatientData;
            // Get list of Patients.
            // New Patient.
            insertPatientData = new Patient_Data__c();
            insertPatientData.Patient_ID__c = PDInfo.strPatientId;
            insertPatientData.First_Name__c = PDInfo.strFirstName;
            insertPatientData.Last_Name__c = PDInfo.strLastName;
            insertPatientData.IsBioCal_Int__c = PDInfo.strIsBioCal;
            insertPatientData.Ethnicity__c = PDInfo.strEthnicity;
            insertPatientData.Asthma__c = PDInfo.strAsthma;
            insertPatientData.Gender__c = PDInfo.strGender;
            insertPatientData.Date_of_Birth__c = PDInfo.dtmDateOfBirth;
            insertPatientData.COPD__c = PDInfo.strCOPD;
            insertPatientData.Height__c = PDInfo.numHeight;
            insertPatientData.Weight__c = PDInfo.numWeight; 
            insertPatientData.Site__c = PDInfo.strsite;
            insert insertPatientData;     
	   return insertPatientData;

Please help.




PDInfo is null and you are trying to access a member of it