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
manuvbkkmanuvbkk 

System.VisualforceException : Dependent class is invalid and needs recompilation

This error seems to be an odd one in that seems to happen when loading a visualforce page first time each day. This page is accessed from a community portal. Subsequent attempts to access the page loads fine, its only the first time each day that we have noticed this.
 
System.VisualforceException : Dependent class is invalid and needs recompilation: Class ClassName : SELECT AccountId, Account.RecordType.Name FROM User ^ERROR at Row:1:Column:19Didn't understand relationship 'Account' in field path.

We tried saving the class here but there are no compilation errors.

Anyone faced seomthing like this before?
Nisar799Nisar799
@Manuvbkk
In Classic
Go to Setup -> Develop -> Apex Classes -> Then Click on "Compile all classes" link. 

In Lightening 
Go to Setup -> Custom Code -> Apex Classes -> Then Click on "Compile all classes" link. 

This will give you error detail about the classes which are failing, Once its done save your code.
mukesh guptamukesh gupta
Hi manuvbkk ,

Here two reason may be:-
Solution 1:-
  1. Class1 : method  calls the method from class2
  2. Class2 : method calls the method from class1
  3. Both classes are depandant on Class3.
  4. Now if I add a variable in Class3 which are used both in Class1 and 2.
  5. Then in class1 comment the code where class2  method is called do changes and save. Then make      changes in class2, save it. Finally uncomment the               method  call in class1.
  6. If its not done then this error will be thrown.
Solution 2:- This errors means that the classes and triggers need to be compiled in your Org. 

1. To compile Classes go to: Setup>> Develop >> Apex Classes 
Click "Compile all classes" Link

2. To compile Triggers go to: Setup>> Develop >> Apex Triggers
Click "Compile all triggers" Link


Follow above process to solve you issue.

Please MARK AS A BEST ANSWER!!!!


Regards
Mukesh