0

I create a trigger on User that only insert/update other 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/organization: 0053000000xxx/00DQ0000003Lxxx Source organization: 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 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 occassionally, meaning someone is firing the trigger.
Any ideas about the meaning of that error? How to troubleshoot this type of error?

  • When the name of the dependent class isn't reported, using the "Compile all Classes" in the "Apex Classes" Setup screen can help identify it. – Keith C Oct 20 '14 at 8:05
  • Reported here mean? – unidha Oct 20 '14 at 8:06
  • When there is an error in a dependent class, a line number is sometimes reported (line 55 in your example) but no class name so it is hard to find the class to fix. (Line 28 is probably in MyHelperClass but that is not the root problem.) – Keith C Oct 20 '14 at 8:11
3

Here's an extra tip in diagnosing the Error: Dependent class is in error and needs recompilation

It is possible that if you get this error in the Force.com 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.

Tip

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 Force.com 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.

2

Here's a second tip on dealing with this error.

Let's say you are manipulating the signatures in the Force.com Enterprise Architecture Service layer. There are three files involved:

  • IMyService
  • MyService
  • MyServiceImpl

If you are refactoring a method signature, it is common to get this error since these three classes are inter-related. You probably already know what you are trying to do but can't figure out which class to change in which order. Each 'approach path' you take ends up with the dependent class needs to be compiled error

The solution (for example, in Eclipse) is to touch each class but not save. That is, the file's tab in the IDE has an asterisk indicating unsaved. Then, use File | Save All so SFDC compiles all the classes together and avoids the dependent class compilation issue.

If you get a new compilation error indicating some syntax error, touch all classes again and repeat File | Save All.

1

As per error message, it looks like there is a class named "MyHelperClass" in your code base. Just open the class and try to save it. If it gives error, resolve the error and it should resolve this issue.

  • No.I saved but still in this morning I receive the exception. – unidha Oct 21 '14 at 6:57
  • @unidha: Are you still getting same error message. Also, can you double check field level permission for Department field on User for your profile? – Anshul Oct 22 '14 at 6:38
  • Yes, @Anshul . This is related to accessibility. – unidha Jan 14 '15 at 9:26
0

I found out the issue happen because the trigger is fired by User who does not have accessibility to Department field.That's is why it said it did not 'No such colum bla bla' and that ' s why I cannot simulate the issue because I have the accessibility to the field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.