Notifications
Announcements
No record found.
So i have a function that contains a list (i don't have access to change the function from list to set)
when i insert to my list, i might insert duplicate values, so i want after finishing everything to remove those duplicate ones. How can i do that?
or is there a way to insert values in a a Set and somehow convert it to List?
Hi junior AX,
How did you get these values of your list?
You could insert the values into a set first, then go through the set and insert values into a list.
I'm going to assume that you're taking values from database, please check the following codes:
List list = new List(Types::String); Set set = new Set(Types::String); while select salestable... { if (set.in(salestable.account)) { continue; } set.add(salestable.account); } SetEnumerator se= set.getEnumerator(); while(se.moveNext()) { list.addEnd(se.current()); }
if you do not want to duplicate, you should use the map , and set the value in the mapkey
Hi Junior AX,
You should not be inserting duplicate values at first place and for this purpose you should be using maps. Also, would you please share your code and scenario so we understand what are you trying to achieve?
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 565 Most Valuable Professional
André Arnaud de Cal... 450 Super User 2025 Season 2
Sohaib Cheema 250 User Group Leader