0
[ExtensionOf(formControlStr(BankReconciliation ,ClearALL))]
 final class ClearAll_Extension
{
    void clicked(){
        next clicked();
        FormRun formrunn = this.FormRun();
        FormDataObject myField;
    
        FormCheckBoxControl BankAccountTrans_Included = formrunn.design().controlName("BankAccountTrans_Included");
        FormDataSource BankAccounttable_ds = formrunn.dataSource("BankAccountTable");
        BankAccountTable BankTable  =  BankAccounttable_ds.cursor();
       // BankAccountTable BankTable ;
        
        FormDataSource BankAccountTran = formrunn.dataSource("BankAccountTrans");
        myField = BankAccountTran.object(fieldnum(BankAccountTrans,Included));
        BankAccountTrans Bankacc  ;
     
        
        ///    Bankacc = BankAccountTran.getFirst();

          //  if(Bankacc.AccountId == BankTable.AccountID)
          //  {
                Bankacc = BankAccountTran.getFirst();
             
                while(Bankacc){
                if (Bankacc.Included == NoYes::No)
                {
                   BankAccountTran.object(fieldNum(BankAccountTrans,Included)).setValue(NoYes::Yes) ;
                 
                }

                else 
                {
                        BankAccountTran.object(fieldNum(BankAccountTrans,Included)).setValue(NoYes::No) ;

                }
                BankAccountTran.write();
                             Bankacc = BankAccountTran.getNext();
               
           
            }

I want to select all record by clicking on (clear all) button and run methods of datasource in all record selected . this button select all records but methods of datasource run on only first record doesn't run on all record , cursor still on first record not moving to the next

FH-Inway
  • 4,432
  • 1
  • 20
  • 37
  • Try `getFirst(true)` as in https://stackoverflow.com/questions/26911202/iterate-through-selected-grid-data-and-get-field-values-of-n-th-datasource. From the [documentation](https://learn.microsoft.com/en-us/dotnet/api/dynamics.ax.application.formdatasource.getfirst): "If the mark parameter is not 0 (zero), the first record that is marked with the specified value is returned, and subsequent calls to the FormDataSource.getNext method return marked records." – FH-Inway Dec 07 '22 at 16:07
  • No , this solution didn't work – Menna Ahmed Dec 07 '22 at 22:24
  • this solution also return only the selected record not all records – Menna Ahmed Dec 07 '22 at 22:31
  • I tired it but the cursor of datasource saw the first record only – Menna Ahmed Dec 07 '22 at 22:40

1 Answers1

0

Why do you need to use datasource methods? If you're doing something on all the records in a table, it makes more sense to do it with a method on the table. Or possibly create a SysOperation and do it in the service class, just loop through all the records. Doing the changes on datasource level makes sense only if you want to change the marked records, in which case you can do it with multiselect.