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
Jyosi jyosiJyosi jyosi 

To get the list of duplicate key in the map

for(Sample_Line SampleLineitem:List_SampleLineItemQuery)
             {
              
                 Map_RejectionSampleLineItem.put(SampleLineitem.Product__c,SampleLineitem.Line_Number__c);
                 }

​​In RejectionSampleLineItem it may contian duplicates Product__c so i will be  missing one key


​ for(Inventory__c Inv :Rejection_InvAdjustment)
                         {
                            
                             MN =
when i get the items because the line number is not present in the map it wont pull the value and it stamps to different line number
Integer.valueOf(Map_RejectionSampleLineItem.get(Inv.Product__c));
                             system.debug('MN Value ====== 511   '+MN);                           

​}​

Is there anyway i can get all the duplicate ids of products.

Thanks

Regards,
Ashok N
 
JeffreyStevensJeffreyStevens
so, instead of having a map<SampleLineItem.Product__c,SampleLineItem.Line_Number__c>, you need a map of Map<SampleLineItem.Product__c,list<SampleLineItem.Line_Number__c>>
Jyosi jyosiJyosi jyosi
but the Map<SampleLineItem.Product__c,list<SampleLineItem.Line_Number__c>> i have the duplicate products id ,but they have diffrent line number .When i keep the debug i will missing one pair .


Thanks

Regards,;p
JeffreyStevensJeffreyStevens
No - if you have data that looks like this...

Product__c      Line_Number__c
A                       1
A                       2

Then you would have a map that looks lke this...
<A,<1,2>>;

For for each Duplicate product - you would have multiple Line Numbers.


Make sense?
Jyosi jyosiJyosi jyosi
Thanks you
But when i excute code
 Map<ID,List<Double>> Map_RejectionSampleLineItem= new Map<ID,List<Double>>();

01t4B0000017JMFQA2=(6.0) and 4 share the same Id ,But i am not able not able to get the 4 reference.

{01t4B0000017JMBQA2=(2.0), 01t4B0000017JMFQA2=(6.0), 01t50000002asuaAAA=(3.0), 01t50000002asvkAAA=(5.0), 01t50000002aswyAAA=(1.0)}

Can you please help me out how to fix this .

Thanks for help.

Regards,
Jyo