web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to detect duplicate values in list and remove them?

(0) ShareShare
ReportReport
Posted on by 1,552

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?

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    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());
    }
    

  • Mark Boy2 Profile Picture
    506 on at

    if you do not want to duplicate, you should use the map , and set the value in the mapkey

  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans