How to retrieve multiple selected records from Grid using X++

How to retrieve multiple selected records from Grid using X++:



In this post, we discuss how we can retrieve all selected(marked) records of a datasource or retrieve marked records form Grid.
For this purpose follow the steps listed below.
  1. Create a new table named "Student" that contains two string fields i.e. Name & ID.
  2. Create a new form and add the newly created "Student" table in the datasource node.
  3. Next create a new button on the form, set its multiselect property to "Yes" . Now override the clicked method of the button and add the following code.
Code snippet

    int             recordsCount;
    Student     studentLocal;
    super();
    
    recordsCount = student_ds.recordsMarked().lastIndex();  // Total number of marked records.
    studentLocal = student_ds.getFirst(1);
    
    while (studentLocal)
    {
        info(studentLocal.Name +" " +studentLocal.ID);
        studentLocal = student_ds.getNext();
    }

//Here when we refresh the previous form,

Object _fds;

_fds = element().args().record().datasource();

after coding after, we need to write

_fds.reReadLines();

Comments

Popular posts from this blog

We will follow the following steps in the AX development.

Need to provide “ItemId lookup” based on "ItemType" field, which selected while creating SalesOrder