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
vanillasky1.3938481563139287E12vanillasky1.3938481563139287E12 

Replace a value in map

I am collecting LOVs from a picklist in a map.

If value==ABCD, replace it with BCDE

Please  help with the replace syntax
KevinBrKevinBr
Try the remove method; fetch the contents, remove, then re-put the data

http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_methods_system_map.htm
(for demo you could replace "SObj" with string.)

map<string,Sobj> mapRecords = new map<string,Sobj>();
mapRecords.put('1234',SObj);
mapRecords.put('5432',SObj);
mapRecords.put('ABCD',Sobj);
if (mapRecords.containsKey('ABCD')) {
  SObj mySobj =  mapRecords.Remove('ABCD'); // value is returned before its removed
  mapRecords.put('BCDE',mySobj');
}