Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Monday, April 3, 2023

Iterate form Datasource in AX2012 /D365 FO

 Hi,

I used the event hander onClicked button to select all the records of lines in datasources 

   public static void Demo_DeleteButton_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        FormButtonControl  callerButton = sender as FormButtonControl;
        FormRun form = callerButton.formRun();
        FormDataSource forecastSales_ds =  form.dataSource(formdatasourcestr(Demo, ForecastSales))  as FormDataSource;
        ForecastSales forecastSalesExpand;
        ttsBegin;
        for(forecastSalesExpand = forecastSales_ds.getFirst(true) ? forecastSales_ds.getFirst(true) : forecastSales_ds.cursor();
forecastSalesExpand; 
forecastSalesExpand = forecastSales_ds.getNext())
        {
            //Perform your operation in forecastSalesExpand;
        }
        forecastSales_ds.executeQuery();
        ttsCommit;
    }

Regards,

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...