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
Pallavi GholePallavi Ghole 

Hello SFDC Gurus - request for help with Triggers on Case object !

I am learnig Apex coding using David Liu's Apex Academy and have a couple triggers on Case object 
WarrantySummary
CheckSecretInformation

All was well till I only had the WarrantySummary trigger but once I created the CheckSecretInformation trigger and try to insert/edit a case I get the error below ==> 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger CheckSecretInformation caused an unexpected exception, contact your administrator: CheckSecretInformation: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, WarrantySummary: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.WarrantySummary: line 5, column 1: []: Trigger.CheckSecretInformation: line 32, column 1


Can you please help ?

Regards
Pallavi
Best Answer chosen by Pallavi Ghole
Jason HardyJason Hardy
You'll need to post your code; however, it sounds like your trying to do something on a variable that hasn't been intiizlied. This is typically seen when you've queried a record and are attempting to do something without checking if it's null. For example, let's say you had a text field that you were trying to do a string fuction against (e.g. equalsIgnoreCase). If it's null and you attempt to run a string function against it, you'll get just such an error. 

All Answers

Jason HardyJason Hardy
You'll need to post your code; however, it sounds like your trying to do something on a variable that hasn't been intiizlied. This is typically seen when you've queried a record and are attempting to do something without checking if it's null. For example, let's say you had a text field that you were trying to do a string fuction against (e.g. equalsIgnoreCase). If it's null and you attempt to run a string function against it, you'll get just such an error. 
This was selected as the best answer
Pallavi GholePallavi Ghole
Thank you so much Jason! Sorry it took so long to check and respond. I will initialize the variable and see how it goes. Thanks once again for replying!