web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How convert While loop in submethod (to remove nested loop Bp)

(0) ShareShare
ReportReport
Posted on by 2

 while select * from custTrans where custTrans.CompanyBankAccountId == bankAccountTable.AccountId
                        
                    {
                        if(custTrans.Voucher == bankAccountTrans.Voucher)
                        {
                            cell  = null;
                            cell  = cells.get_Item(currentRow, 3);
                            cell.set_Value(custTrans.AccountNum);

                            cell  = null;
                            cell  = cells.get_Item(currentRow, 4);
                            cell.set_Value(custTrans.custTableName());

                            cell  = null;
                            cell  = cells.get_Item(currentRow, 5);
                            cell.set_Value(Global::OAIGetDimensionDisplayValue(custTable.DefaultDimension,"@OAB:OABBusinessUnitnew"));
                
                            cell  = null;
                            cell  = cells.get_Item(currentRow, 6);
                            cell.set_Value(custTable.InventLocation );

                            cell  = null;
                            cell  = cells.get_Item(currentRow, 7);
                            cell.set_Value(enum2Str(custTrans.TransType));
                        }
                    }

please help me convert this piece of code into a method.Thankyouu !!

I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: How convert While loop in submethod (to remove nested loop Bp)

    Hi Sachin, you can try creating and calling below code. Please change cell EDT or object in the parameter. Either keep method return type void or return cell, based on your customization. You might get compilation error for custTable, in that case just create one more parameter for custTable.

    public void setCustTransValues(CompanyBankAccountId _bankAccountId, Voucher _voucher, CellEDT cell)
    {
         while select * from custTrans 
        where custTrans.CompanyBankAccountId == _bankAccountId
        && custTrans.Voucher == _voucher
        {
                cell  = null;
                cell  = cells.get_Item(currentRow, 3);
                cell.set_Value(custTrans.AccountNum);
        
                cell  = null;
                cell  = cells.get_Item(currentRow, 4);
                cell.set_Value(custTrans.custTableName());
        
                cell  = null;
                cell  = cells.get_Item(currentRow, 5);
                cell.set_Value(Global::OAIGetDimensionDisplayValue(custTable.DefaultDimension,"@OAB:OABBusinessUnitnew"));
        
                cell  = null;
                cell  = cells.get_Item(currentRow, 6);
                cell.set_Value(custTable.InventLocation );
        
                cell  = null;
                cell  = cells.get_Item(currentRow, 7);
                cell.set_Value(enum2Str(custTrans.TransType));
        }
    }

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: How convert While loop in submethod (to remove nested loop Bp)

    To remove nested while loope create new method and in this method you can put the first while loop there. Pass the argument to the method with the values from 1st while loop.

    Other option will be supressing the warning.

    Thanks,

    Girish S.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

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

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 569

#3
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans