+ Start a Discussion
amateur1amateur1 

values getting overwrite in map

hi here i am creating a map and i have 6 values in the query but only the last value is getting into the map. how to get all the 6 values

 

for(ROI_Visualization_Calulator_Line_Item__c rvc:[select id,name,ROI_Visualization__c from ROI_Visualization_Calulator_Line_Item__c where ROI_Visualization__c in:trigger.newmap.keyset()])
{
mapRoi.put(rvc.ROI_Visualization__c ,rvc);

}

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

In the map the key should be unique. If a key has two values in map the previous value will overwrite with new value. So please check the six values you are getting have same rvc.ROI_Visualization__c or different values.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

In the map the key should be unique. If a key has two values in map the previous value will overwrite with new value. So please check the six values you are getting have same rvc.ROI_Visualization__c or different values.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
amateur1amateur1

yes the six values have same rvc.ROI_Visualization__c  but i am getting only the last value how to get all the six values into map

Waqar Hussain SFWaqar Hussain SF
In map, we can get only unique values. we cannot get all values in the map