Illegal Asiignment From List To Map
Please Help Me On This Error
Illegal Asiignment From List To Map
Please Help Me On This Error
You can't assign, the types are incompatible. You can use the map constructor that takes a list as argument
Map<Id, Account> myMap = new Map<Id, Account>([SELECT Id, Name FROM Account LIMIT 10]);
or if you have existing map - you can call putAll
on it.
Map<Id, Account> myMap = new Map<Id, Account>();
// some other code, maybe even adding some items to map manually
// and eventually
myMap.putAll([SELECT Id, Name FROM Account LIMIT 10]);