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

Parsing string to csv and passing it to List Control

(0) ShareShare
ReportReport
Posted on by

Hi All,

I have a string returned by API which I need to parse to csv or any other format supported by List Box (or List View) and display on Form.

How to parse string to csv in X++?

However, I didn't find much info about List Box or List View so would appreciate your help in choosing right control and examples how to pass data to it.

Thank you!

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    You don't need a CSV when setting up a ListBox or ListView, so there's no need to parse text into CSV. 

    Did you mean that the API returns a CSV and you want to populate a ListBox/ListView with the values from the CSV? 

    If yes, you could cast the CSV into a container with str2con function, and then iterate the container to add elements to ListBox or ListView.

    If no, then you need to let us know the format of the information that you get from the API. 

    I found a lot of examples of ListView and ListBox by web search, here's one: axbeginners.blogspot.com/.../listviewcontrol-in-dynamics-ax.html

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

    You can't parse text to CSV. CSV is a text format, therefore you can either parse CSV text to something you can work with, or you can take data and serialize it to CSV.

    Also, you can't simply pass CSV to those form controls, therefore your design wouldn't work.

    Before we can tell you how you can parse the string returned by the API, you'll have to tell which format it's using.

    A better option than using List Box or List View controls may be putting the data to a temporary table and displaying it in a grid.

  • Community Member Profile Picture
    on at

    I have str variable which looks like usual CSV seperetad by comma

    "Header1", "Header2", "Header3"

    "Value1", "Value2", "Value3"

    ...             ...              ...

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    So, you have a CSV.

    Then you can follow the approach that I suggested in my earlier message (as mentioned in that message).

  • Community Member Profile Picture
    on at

    Thank you for help!

    I saw the article you sent but didn't find how to add multiple columns and data to them

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

    If you need multiple columns, the right type of control is grid. As I mentioned, you can insert records with the data into a temporary table and use this temporary table as the data source of a grid.

  • Community Member Profile Picture
    on at

    So, List View doesn't support multiple columns, right?

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

    It does - you can use addColumn() method.

    But there is a reason why grids, rather then list views, are normally used for showing tabular data. For example, they allow users to easily sort and filter data.

  • Community Member Profile Picture
    on at

    I have a requirement to use list.

    When we do addColumn() method how then we insert data to different columns?

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

    A requirement? Why? What's the business requirement leading to this technical requirement? What if I confirmed your statement that it can't be done? Would it still be a requirement? Would you tell the client that showing the data is impossible, or would you accept that the type of control is an implementation detail and you can implement the business requirement in different ways?

    Anyway, this is an example how you can create multiple columns in a list view and set some values:

    listView.addColumn(1, new FormListColumn("First"));
    listView.addColumn(2, new FormListColumn("Second"));
    
    FormListItem item = new FormListItem();
    int idx = listView.addItem(item);
    listView.setText(idx, "Value A", 0);
    listView.setText(idx, "Value B", 1);

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans