+ Start a Discussion
SUBHAJIT PALSUBHAJIT PAL 

getting multiple values against a key in a map when map defination is map<id,decimal>

public Map<id,decimal>MRCDISCMAP{get;set;}
public Map<id,decimal>NRCDISCMAP{get;set;}
MRCDISCMAP=new map<id,decimal>();
NRCDISCMAP=new map<id,decimal>();

system.debug('#########Inside Save NRCmap'+NRCDISCMAP.get('a0zO0000000VofUIAS')+'\n'+NRCDISCMAP.keyset()+'\n'+NRCDISCMAP.keyset().size()+
                '\n'+NRCDISCMAP.values()+'\n'+NRCDISCMAP.values().size());

for(Opportunity_line__c oprl:[SELECT id,name from Opportunity_line__c where id in:localmapNRC.keyset() or id in:localmapMRC.keyset()])
        {
            system.debug('1111Inside Save local NRCmap'+localmapNRC);
            system.debug('22222Inside Save local MRCmap'+localmapMRC);
            
            system.debug('Inside Save NRCmap>>local'+oprl.id+'::'+localmapNRC.get(oprl.id));
            system.debug('Inside Save MRCmap>>local'+oprl.id+'::'+localmapMRC.get(oprl.id));
            
            oprl.NRC_Discount__c=localmapNRC.get(oprl.id);
            oprl.MRC_Discount__c=localmapMRC.get(oprl.id);
            OPLlist.add(oprl);
        }

 Above is the part of the controller class of a page.

 

VISUAL FORCE PAGE:

 

<apex:inputText value="{!NRCDISCMAP[PA2.Opportunity_Line__c]}" onchange="changeVal();"/>---inside apex repeat

 

I am using the map in the page bcoz inputtext is inside apex:repeat. so i am trying to get the new values in map. and use them in class to update some data in Sobject.

 

but when i'm tring to get values from map it showing old value. And when i am printing map values[map.values()] its showing both old and new values.

 

DEBUG LOG:::

#########Inside Save NRCmap17
{a0zO0000000VofUIAS}
2
(9999, 17)
2

In 2nd line of debug map.keyset()

in 3rd line of debug map.keyset().size()

4th line of debug map.values()

5h line of debug map.values().size()

 

if its printing 1 key[id] then how can its size be 2, and its storing 2 values against a key when map defintion is <id,decimal>

 

and my problem is when i am tring to get value from map its returning only the old value.[here 9999 is new value that is set from page and 17 is the old value]