line -1, column -1: Previous load of class failed: – In most scenarios, this error message is related to the “IsValid” checkbox for the code which is being referred to in the message.
“IsValid” Checkbox is unchecked for an Apex Class or a Trigger when the metadata on which the code is dependent, has been changed and the code is not compiled after that. The code can be compiled by running the Run All Test, or clicking “Compile All Classes” link, or by Editing and saving that class, or by executing the code in the class. When the code is compiled, either an error message is displayed which can be rectified, or the code is saved successfully and the isValid checkbox is checked.
Invalid Class/Trigger will cause this issue in the org. You can query and check if any invalid classes or triggers in you org from ApexClass and ApexTrigger like below.
Select Id, IsValid, Name From ApexClass where isValid=false
Select Id, IsValid, Name From ApexTrigger where isValid=false
Apex classes are stored with an isValid flag that is set to true as long as dependent metadata has not changed since the class was last compiled. If any changes are made to object names or fields that are used in the class, including superficial changes such as edits to an object or field description, or if changes are made to a class that calls this class, the isValid flag is set to false. When a trigger or Web service call invokes the class, the code is recompiled and the user is notified if there are any errors. If there are no errors, the isValid flag is reset.
Triggers are stored with an isValid flag that is set to true as long as dependent metadata has not changed since the trigger was last compiled. If any changes are made to object names or fields that are used in the trigger, including superficial changes such as edits to an object or field description, the isValid flag is set to false until the Apex compiler reprocesses the code. Recompiling occurs when the trigger is next executed, or when a user re-saves the trigger in metadata.
Resolution – To resolve this error recompile all classes and do the changes if any class failed to compiled as per the error message.
Steps To Compile All Classes .
Setup > Apex Classes – Click on the “Complie all Classes” link as below.