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
Nandhini S 3Nandhini S 3 

How to get a specific field value from map?

Hi Guys,

I have a map, map<id, List<customObject>>.
How to get a specifc custom field of the custom object from the map?
jobsvjobsv

Hello!

You can retrieve the values from a especific key or in a loop:
 

myMap.get(key).get(index).Field_1__c


or
 

for(Id forId : myMap.keySet()){
	for(customObject co : myMap.get(forId).values()){
		// co.Field_1__c ...
        // co.Field_2__c ...
	}
}
 


More information you can get in this link:

https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_map.htm

sakhisakhi
Hi Nandhini ,

let say we have dummymap

map<id,List<Dummy__c>> = new dummymap<id,List<Dummy__c>>();

Let say we want to take value of dummyfield__c from Dummy__c

for(id id:dummymap.keyset()){
    string fieldvalue = dummymap.get(id).dummyfield__c;
}

Hope it helps , else paste your code
Nandhini S 3Nandhini S 3
Hi Jobsv,

Thanks for replying. What would be the index to get the customfield value.