You need to sign in to do that
Don't have an account?
Kurt Almeida
Illegal assignment from LIST<Account> to LIST<Account>
I am receivin this general error.
This is in our sandbox environment. We were able to use our sandbox without any issues a few days ago. We didn't make any change to our code. Today, we received this error. We ran a debug log and couldnt find anything either. What is going on?
Error(s) occurred while submitting the page. The error details are: An exception was encountered when attempting to populate default value: (System.TypeException)Illegal assignment from List<Account> to Account
This is in our sandbox environment. We were able to use our sandbox without any issues a few days ago. We didn't make any change to our code. Today, we received this error. We ran a debug log and couldnt find anything either. What is going on?
You will get this when you are expectng n result from SOQL, but it is giving more than one record.
e.g.
Account queriedAccount = [Select Id from Account Limit 1];
The above will work fine always as you are limiting return record to 1.
But If you remove limit 1 from SOQL as shown in below SOQL query, then you query will return List<Account> instead single Account record; this time you will get the same error what you are getting currently.
Account queriedAccount = [Select Id from Account]; // to avoid such error we should use list always as below.
// best practise
List<Account> queriedAccount = [Select Id from Account];// this will never throw such error.
Please let me know if it helps you.
Regards,
Pawan Kumar
All Answers
You will get this when you are expectng n result from SOQL, but it is giving more than one record.
e.g.
Account queriedAccount = [Select Id from Account Limit 1];
The above will work fine always as you are limiting return record to 1.
But If you remove limit 1 from SOQL as shown in below SOQL query, then you query will return List<Account> instead single Account record; this time you will get the same error what you are getting currently.
Account queriedAccount = [Select Id from Account]; // to avoid such error we should use list always as below.
// best practise
List<Account> queriedAccount = [Select Id from Account];// this will never throw such error.
Please let me know if it helps you.
Regards,
Pawan Kumar