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
mobile vistexmobile vistex 

how to push map data into a list

hi iam actually trying to prepare a table where i want to push map data into list ? what is the approach to move data of map to a list in apex
SathyaTrekbin TechSathyaTrekbin Tech
Hi Vistex,

See the below snippet for pushing map data into a list:
 
List<String> lstData = new List<String>();
//add all map values into the list 
lstData.addAll(mapData.Values());

Hopefully, this helps you!

Thanks,
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Hi ,

Use Map values() method as below.
Map<Id,Account> mapAccounts = new Map<Id,Account>();

mapAccounts.values(); // This is basically a list now of type List<Account>

 
Suraj Tripathi 47Suraj Tripathi 47
Hi,

"Try this code."
for this, you need to use the values() method.
Eg.
Map ObjectName is mapObj.
So you need to write mapObj.values();
List<String> listObj=new List<String>();
listObj.add(mapObj.values());


If you find your Solution then mark this as the best answer. 

Thank you!

Regards,
Suraj Tripathi