You need to sign in to do that
Don't have an account?
Accessing fields of Account from Map<String, List<Account>>
Hello There,
I have a Map i.e., Map<String, List<Account>> emailAccListMap
I am trying to access the account field from the above Map by saying emailAccListMap.get(String).Name, but this doesn't work.
Can anyone help?
Thanks
I have a Map i.e., Map<String, List<Account>> emailAccListMap
I am trying to access the account field from the above Map by saying emailAccListMap.get(String).Name, but this doesn't work.
Can anyone help?
Thanks
like
for (Account acc : emailAccListMap.get(String)){
acc.name;
}
All Answers
like
for (Account acc : emailAccListMap.get(String)){
acc.name;
}
The solution is simple, If you want to get Account record from the map then using key we can get it. In your code, You mentioned "string" as a key in the Map. So we can get using Accountname. Rest you can understand with the help of code I have provided below.
for(account a:trigger.new){
List<Account> acc=emailAccListMap.get(a.Name);
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Arun Chowdary