Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Choosing a bank account to print in a report.

(0) ShareShare
ReportReport
Posted on by

Hello.

I'm new to Nav coding, so please don't be mad at me. And i'm not native english speaker.

So, I have a task:

I need to show different bank accounts of my company in a report (MS Word), it depends of Customer Agreement Line (seems like it was added by previous IT-dude) containment. Table Customer Agreement Line contain rows like Building, Floor, Item, Area etc.

For example - I need to print a report for customer AAA, which is renting an item at Building Delta, so I need to use Bank Account 1. Then I need to make a report for customer BBB, which is renting an item at Building Bravo, so I need to use Bank Account 2 for same report. 

As I see, I need to check a building code in "AfterGetRecord" trigger. I can do that. But how can I choose one of Bank Accounts for report?

I understand IF ELSE logic, but I still not figured out how can I work with selections from tables. I see something like this:

IF CustAgreementLine.Building='Delta" THEN BEGIN

Select * From BankAccounts where BankAccounts.No=1

BankName:=BankAccounts.Name

BankBIC=BankAccount.BIC

END;

Obviously, standard SQL queries ain't work like this in NAV, I think there must be some temporary table, which is filled with records, that match my query terms. And the records from temp table will be shown in a report.

So I need help with it-)

*This post is locked for comments

  • RE: Choosing a bank account to print in a report.

    I did this!

    Thank for your help.

    Everything is work fine.

    I made two mistakes:

    In a xml-layout I take wrong variables and I used ELSE IF instead of IF in a second section. So I made it right!

  • RE: Choosing a bank account to print in a report.

    Hello!

    Thank you for help.

    But I still have problem with it.

    BankName:='';
    BIC:='';
    
    IF CustAgreementLineOld."Corpus No."<>'Delta' THEN BEGIN
     "Bank Account".GET('BA-00002');
    BankName:=("Bank Account".Name);
    BIC:=  "Bank Account"."Bank BIC";
    message(bankname)  ;
     END
    ELSE IF CustAgreementLineOld."Corpus No."='Bravo' THEN  BEGIN
     "Bank Account".GET('BA-00001');
     BankName:="Bank Account".Name;
     MESSAGE(BankName);
     END;

    So, when IF ELSE is work, I can see a message with a proper bank account. But in a report I still see wrong bankname.

    I add variables BankName and BIC in integer block, set up an XML-layout, but when I print it - I see a message with a proper BankName and a report with a wrong one...

  • Verified answer
    Tharanga Chandrasekara Profile Picture
    Tharanga Chandrasekara 23,116 on at
    RE: Choosing a bank account to print in a report.

    We normally do not share the code on forum unless the member has not given a proper try, however I feel that you need a help to start your development stage, so here we go..

    You can check few books from this website : https://www.packtpub.com/all?search=Dynamics%20NAV

    Few links to startup in MSDN : https://msdn.microsoft.com/en-us/library/dd338869.aspx

    https://msdn.microsoft.com/en-us/library/ee414204.aspx

    https://msdn.microsoft.com/en-us/library/ee414237.aspx

  • Verified answer
    Tharanga Chandrasekara Profile Picture
    Tharanga Chandrasekara 23,116 on at
    RE: Choosing a bank account to print in a report.

    This is how the code should look like for your solution,

    BankName:= '';
    BankBIC := '';
    IF CustAgreementLine.Building = 'Delta" THEN BEGIN
     BankAccounts.GET('BankAccountNo.');
     BankName:= BankAccounts.Name;
     BankBIC := Bankaccounts."Account No.";
    END
    ELSE IF CustAgreementline.Building = "Bravo" THEN BEGIN
     BankAccounts.GET('BankAccountNo.');
     BankName:= BankAccounts.Name;
     BankBIC := Bankaccounts."Account No.";
    END;


    However if you can add a new field to the CustAgreementLine table and link it with the Bank account then your code can be simplify, otherwise for each and every new bank you need to come back and modify the code. New code will look like below

    BankName:= '';
    BankBIC := '';
    BankAccounts.RESET;
    BankAccounts.SETFILTER(BankAccounts."No.",CustAgreementLine."Bank Account No.");
    IF BankAccounts.FINDFIRST THEN BEGIN
       BankName:= BankAccounts.Name;
       BankBIC := Bankaccounts."Account No.";
    END;

    While sharing the code, I do suggest you to start reading on some NAV development documents on MSDN.

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Choosing a bank account to print in a report.

    Hi,

    By looking at the requirement

    You can write something like this

    IF CustAgreementLine.Building='Delta" THEN BEGIN

     BankAccounts.GET('1') --->Replace with your bank account no

     BankName:- BankAccounts.Name

     BankBIC :- Bankaccounts.BIC

    END

    ELSE IF CustAgreementline.Building="Delata1" THEN BEGIN

      BankAccounts.GET('2') --->Replace with your bank account no

     BankName:- BankAccounts.Name

     BankBIC :- Bankaccounts.BIC

    END;

    Hope this will help you

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans