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

Announcements

No record found.

News and Announcements icon
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 6

 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 !!

  • Suggested answer
    Mohit Rampal Profile Picture
    12,573 Moderator on at

    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,845 Moderator on at

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 264 Super User 2026 Season 2

#2
Aayush Tiwari Profile Picture

Aayush Tiwari 219

#3
Subra Profile Picture

Subra 164 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans