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

Attempt to deference a null object

Hi All,


I have written two apex classes in sandbox. Code for both the classes are similar except  type being differnet. I have two types of opportunities ie. recurrig and non-recurring. So the only difference in code is for type of opportunity. Rest of the code is same for both the classes.They are working fine in sandbox. But when I deploy these to production, One class

works well but for the other I get an error saying "Attempt to derefernce a null object".


I am unable to understand why I am getting this error when it is working fine in sandbox .Can someone please give me some pointer/reason why I am getting this error and solution.





You'll need to post your code

Anup JadhavAnup Jadhav

It is most likely that you have not instantiated the variable, or are using reference variable like var__r.ref1__r.ref2__2, and ref1__r is not initialized.


- Anup