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

code is not working can you please help!!

(0) ShareShare
ReportReport
Posted on by 2

 while (qr.next())
            {
                bankAccountTable		= qr.get(tableNum(BankAccountTable));
                bankAccountTrans			= qr.get(tableNum(BankAccountTrans));
                
                if(bankAccountTable.OABcashAccount == NoYes::Yes)
                {
                  
                    select sum(AmountCur) from bankAccountTransLocal where bankAccountTransLocal.TransDate < fromDate &&
                        bankAccountTransLocal.AccountId == bankAccountTrans.AccountId;
                    closingBalance = bankAccountTransLocal.AmountCur;
                    currentRow  ;
                    
                    cell  = null;
                    cell  = cells.get_Item(currentRow, 1);
                    cell.set_Value(this.strDate(bankAccountTrans.TransDate));

                    cell  = null;
                    cell  = cells.get_Item(currentRow, 2);
                    cell.set_Value(bankAccountTrans.Voucher);

                   while  select * from ledgerJournalTrans where LedgerJournalTrans.BankAccountId ==  bankAccountTable.AccountId

                    while select * from vendtrans where vendtrans.CompanyBankAccountId == bankAccountTable.AccountId
                        join vendTable where vendTable.AccountNum == vendtrans.AccountNum

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

                        cell  = null;
                        cell  = cells.get_Item(currentRow, 4);
                        cell.set_Value(vendtrans.vendTableName());

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

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

                    else 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));

                    }
                     else if (ledgerJournalTrans.Voucher == bankAccountTrans.Voucher)
                   {
                        cell  = null;
                        cell  = cells.get_Item(currentRow, 3);
                       cell.set_Value('');

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

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

                        cell  = null;
                        cell  = cells.get_Item(currentRow, 6);
                        cell.set_Value('');

                       cell  = null;
                        cell  = cells.get_Item(currentRow, 7);
                        cell.set_Value(enum2Str(ledgerJournalTrans.TransactionType));

                    }

when i remove ledgerjournaltrans while select statement code shows data from 3 to 7 column , dont know what is happening can you please help out totally stuck on it

I have the same question (0)
  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi Sachin, May I know why do you need nested while loops here. Please let us know your requirement and from where are you removing ledgerjournaltrans.

  • Sachin Mittal Profile Picture
    2 on at

    22 line , requirement is from Bank account trans all transactions needs to be printed for a bank account , now for these transactions it can be of vendor , customer , or ledgerjournal . and it can ne multiple transactions so i added while but when i add 22 line code cells show empty values ,  and is there any way to combine these three while statements ?

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

    I would have divided this one method into multiple methods for better readability. For instance, Line# 24 to 52 (excluding while select for customer) will go into different method and same for Customer and Ledger.

    If a bank account can have transactions from Customer, Vendor and Ledger then call these methods one by one. However, if not then you can write switch statement or if else based on Voucher so only one gets executed. Also, you can check voucher within while loop as below

    while select * from vendtrans where vendtrans.CompanyBankAccountId == bankAccountTable.AccountId
        && vendtrans.Voucher == bankAccountTrans.Voucher 
    join vendTable where vendTable.AccountNum == vendtrans.AccountNum

  • André Arnaud de Calavon Profile Picture
    303,503 Super User 2026 Season 1 on at

    Hi Sachin,

    Can you tell if you get errors or what exactly you mean with "code is not working"? What is the current behavior and what is the expectation?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 518 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 431

#3
Adis Profile Picture

Adis 280 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans