web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    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

  • Verified answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at

    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.

  • Verified answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at

    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

  • Community Member Profile Picture
    on at

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

  • Community Member Profile Picture
    on at

    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!

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans