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
Bhaskar ChowdaryBhaskar Chowdary 

Preventing System.ListException: Duplicate id in list:

Hello every one I have a requirement like dont allo duplicate recoreds in my related list .

I created wrapper class that contains checkbox with selected questions

if select check box and click on button copy the selected questions to my related list that is lookup so here every time duplicated records also coming into that so how to restrict that by using apex please send any sample code to



Add those list values to a set. Set contains unique data.


List<String> strList = new List<String>();


Set<String> strSet = new Set<String>();