Apex/Visualforce common errors and how to fix

In this post we will discuss common errors that we will come across when using apex or visualforce and solutions to fix these common errors.

Apex Errors

  • System.NullPointerException: Attempt to de-reference a null object 
This is the most common error that everybody faces, if they are starting coding in apex without much prior experience in programming languages. This error occurs when user is trying to do some operation in null object. For example if you are trying to access a variable in an object instance it will give this error.

    Mostly this error is because of not considering null scenarios in coding. If you are facing this error, go ahead to the link mentioned in the error and make sure that the variable is not null. Once in the above code all variables are initialized properly, it will look like below,

No comments:

Post a Comment