How to troubleshoot the 'Dependent class is invalid and needs > recompilation' exception?

542    Asked by ClareMatthews in Salesforce , Asked on May 4, 2023

I create a trigger on User that only inserts/updates another table when there are changes/insertions into the Department field that belong to User. It's working fine except sometimes I receive this exception in my email:

Apex script unhandled trigger exception by user/organisation: 0053000000xxx/00DQ0000003Lxxx Source organisation: 00D00000000hxxx (null) MyUpdateTrigger: execution of BeforeUpdate

caused by: line 55, column 24: Dependent class is invalid and needs recompilation: MyHelperClass: line 28, column 30: No such column 'Department' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

I check the line number: it points to an empty line.
The Department api name has no __c at the end.
I don't receive an email on this error when I do a manual test. I just received an email occasionally, meaning someone is firing the trigger.
Any ideas about the meaning of that error? How to troubleshoot this type of error?
Answered by Claudine Tippins

To diagnose the Error: Dependent class is in error and needs recompilation It is possible that if you get this error in the Eclipse IDE, there will be no further diagnostic information beyond the line number of the class being compiled that references some dependent class (which could be the dependent of a dependent ...). You're left puzzling over where the problem could be.


Copy-paste your code from Eclipse IDE into the Developer Console file for the same class and click Save. The Developer Console will report the full error message with a direct pointer to the underlying class that is in error
UPDATE for Eclipse: Turns out if you hover over the error line in Eclipse (tested in V38 IDE), the full detailed explanation as to which class is at issue will appear. You don't need to go to the Developer Console.
Here's an example:
From Eclipse IDE
Dependent class is in error and needs recompilation Line 14
From Developer Console
Dependent class is in error and needs recompilation Line 14, Class Foo line 56 method has incorrect signature (..)
where Foo is the dependent class in error and line 56 tells you why it is in error.

Your Answer


Parent Categories