Link to home
Start Free TrialLog in
Avatar of Bharat Guru
Bharat Guru

asked on

How to split the map object in Apex

how to split the map from sql result by filtering the value.

Map<string, AccountList> AccountListMap = new Map<String, [Select Id, Name, AccountType  from Accoount where AccountType in ('A','B','C')]>;

How can I get AccountListMap for only AccoountType = 'A'     or AccoountType = 'B'   ?
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Try using List<Account> then loop through the list and add each account to the correct part of the map.
Avatar of Bharat Guru
Bharat Guru

ASKER

please provide the sample
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is there anyway to filter map<I’d,Account> without for loop and set it to new map?
AFAIK, you cannot without iterating the map.