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, ...
Answered

Is there a search feature in a list or collection ?

(0) ShareShare
ReportReport
Posted on by

Hello everyone,

Is there a search for specific word in a list or a collection ?

If for example I'm listing my tables with this code :

IList listTables = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::tableNames();

Can I loop and find some word, for example with the word "Sales" ?

Or should I use Collection ?

Thanks,

I have the same question (0)
  • Blue Wang Profile Picture
    on at

    Hi Voltes,

    You can use Set.

    https://docs.microsoft.com/en-us/previous-versions/dynamicsax-2009/developer/aa861938(v=ax.50)?redirectedfrom=MSDN

    List no such a method, you have to iterate its elements.

  • WillWU Profile Picture
    22,361 on at

    Hi VoltesDev,

    You can use ListIterator to traverse your list:

    docs.microsoft.com/.../x-csharp-comparison-collections

    List  list = new List(Types::String);

    ListIterator  iterator = new ListIterator(list);

       while(iterator.more())

       {

           info(iterator.value());

           iterator.next();

       }

  • VoltesDev Profile Picture
    on at

    Hi both,

    I'm sorry, can I have a sample in real case. I have a trouble every time looking at Microsoft docs.

    Also it seems both of you replying in contradiction, if I'm not miss understood. And btw have u know the different between ListIterator and IList ?

    I saw in one of standard class is using IList, ?

    My intentions is still, I need to have a list of tables in AOT, but I want to process only tables with names contains word "Sales"

    Thanks,

  • Verified answer
    WillWU Profile Picture
    22,361 on at

    Hi voltes,

    Sorry for my mistake.

    So what you need is:

    var tables = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::TableNames();  

        while (tables.MoveNext())  

        {  

           str tablename=tables.Current;  

        }  

    And you could use strFind() or strScan() to find the names you want.

  • Verified answer
    Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    List is an X++ class representing a list of values. ListIterator is an X++ used to iterate elements of a List object.

    IList is a managed (.NET) interface from System.Collections namespace. It's an abstraction of a list of values - concrete implementations include System.Collections.ArrayList and System.Collections.Generics.List<T>, for example.

    Because IList isn't the same thing as List class, you can't use ListIterator for it. But you can use managed classes and frameworks, such as IEnumerator (tables.GetEnumerator()) or LINQ.

  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    If you create a C# project, you can utilize LINQ in a way like this:

    foreach (string tableName = tableNames.Where(t => t.Contains("Sales")))
    {
    	...
    }

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 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans