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
diydiy 

How can i remove duplicate product in my code?

My requirement is

 I have 3 product in one object and 6 serial number in another object.. serial number related to product.. Datas are p1 -> s1,s2 p2 ->s3,s4 p3->s5,s6..  In my UI have 2 page block table.. 1st page block table I enter serial number s1,s2,s3 ... my 2nd pageblock wil display p1 and p2 ... but its display p1,p1 and p2.. duplicate value display.. How can I resolve this issue? my code is..

public void productadd (){

for(integer i=0;i<AssetAddList.size();i++ ){          
    ProductList = [select id,Product_Number__c,Product_Number__r.name,Serial_Number__c from Equipment_Master__c where Serial_Number__c   =:  AssetAddList[i].Serial_Number__c ];

    serialIncConfigsItem[i].Product_Number__c = ProductList.Product_Number__c;


}
 

  AssetAddlist - > Enter serial number page block table
  serialIncConfigsItem -> display product

 

How can i remove duplicate product in my code?

Abhi_TripathiAbhi_Tripathi

Hey Diya,

 

You should use MAP, beacuase its having key as uniques where you can use prodcut Id and values will be your page block.

 

Take a look at this post how to populate your map, with unique key and repeated values

http://abhithetechknight.blogspot.in/2013/10/logic-for-maps-having-list-at-values.html