Tuesday, 9 September 2014

Loop through Grid Selected records :AX2012 : X++ code to access marked records on a form

Write code in form method as Set button property as Multiselection property yes
void clicked()
{
    StudentInformation studentInformationloc;
    StudentDetails     studentDetails;
    super();
    //recordcount = ReservationCancellation_ds.recordsMarked().lastIndex();
    studentInformationloc = studentInformation_ds.getFirst(1);
    while(studentInformationloc)
    {
    studentDetails.Course = studentInformationloc.Course;
    //info(strFmt("%1",ReservationCancellationloc.Status));
    studentDetails.insert();
    studentInformationloc = studentInformation_ds.getNext();
    }
    studentInformation_ds.refresh();
    studentInformation_ds.research();


}

This code is for we select multi record and click on button then that records fields insert in to another table

1. Add a new button on the form.
2. Set property "MultiSelect" to Yes.
3. Override the clicked method of the button and code as shown below :




Inside the for loop you can write the logic which you want to process.


No comments:

Post a Comment