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
Srikanth Challa 3Srikanth Challa 3 

All the triggers are throwing error in Sandbox

Hi Guys, today I tried to edit the records in Sandbox and they started throwing me an error saying that 'Error:Dependent class is invalid and needs recompilation'. when I tried to edit the class and saved it then it is throwing '[Error] Error: Compile Error: Illegal assignment from List<Account> to List<Account> ' . I wonder why all the triggers in sandbox are throwing errors where they are working perfectly in Production!
Best Answer chosen by Srikanth Challa 3
James LoghryJames Loghry
Do you have an Apex class called "Account" in your sandbox?  If so, that would explain all the issues you're having. If that's the case, you should refactor/rename or delete the Account class

All Answers

James LoghryJames Loghry
It's likely that someone made a change in sandbox.  One that allowed them to compile the class they were working on, but then broke all other classes depending on it, hence the error you're getting.  You'll need to fix the class that was modified, or if the method or class signatures changed, then you'll need to update on classes that depend on those changes.  

The dependent class may have been modified on the sandbox and not in production, or production may have a similar issue too if you haven't checked already.
Srikanth Challa 3Srikanth Challa 3
Even this trigger is not working : [Error] Error: Compile Error: Variable does not exist: Description at line 3 column 9
trigger Updatedesc on Account (before insert, before update) {
    for (Account updatedAccount : Trigger.new) {
        updatedAccount.Description = 'New Description';
        insert updatedAccount;
    }
}
Srikanth Challa 3Srikanth Challa 3
WHich even Apex class I write on Accounts object the same error is showing up 

Variable does not exist: 'Field Name'. It is unable to recognise the field for some reason
 
Amit Chaudhary 8Amit Chaudhary 8
Please try below code :-
trigger Updatedesc on Account (before insert, before update) 
{
    for (Account updatedAccount : Trigger.new) 
    {
        updatedAccount.Description = 'New Description';
    }
}
Now i am able to save above code 
User-added image

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_account.htm


Please mark this as solution if this will resolve you problem
 
Srikanth Challa 3Srikanth Challa 3
The same error shows up. What ever field I select it is throwing an error saying that the variable doesn't exist. I registered a case with salesforce and they said that they are not going to look at code without premium support. It's not about the code it is some Issue with my sandbox.
Srikanth Challa 3Srikanth Challa 3
User-added image
James LoghryJames Loghry
Do you have an Apex class called "Account" in your sandbox?  If so, that would explain all the issues you're having. If that's the case, you should refactor/rename or delete the Account class
This was selected as the best answer
Srikanth Challa 3Srikanth Challa 3

Thanks a lot James!

 

James LoghryJames Loghry
Ha.  I feel you, as these have plagued me from time to time as well.  If you could, please upvote this idea: https://success.salesforce.com/ideaView?id=08730000000kyIQAAY&sort=2 (https://success.salesforce.com/ideaView?id=08730000000kyIQAAY&sort=2)