GET Function

supp85
Member Posts: 76
Hello all,
I am trying to add vendor bank details to the remittance advice report, however i keep getting an error when i enter the following code within the onaftergetrecord of the Vendor Ledger Entry data item
Vend: Vendor table
VendBankAcc: Vendoor bank account table
Can anyone help please?
I am trying to add vendor bank details to the remittance advice report, however i keep getting an error when i enter the following code within the onaftergetrecord of the Vendor Ledger Entry data item
Vend: Vendor table
VendBankAcc: Vendoor bank account table
IF Vend."BACS Account No." <>'' THEN BEGIN VendBankAcc.GET("Vendor No.",Code) THEN BEGIN BankSC := VendBankAcc."Bank Branch No."; BankAcc := VendBankAcc."Bank Account No."; END;
Can anyone help please?
0
Answers
-
You are missing a second IF statement (and corresponding END statement):
IF Vend."BACS Account No." <>'' THEN BEGIN
IF VendBankAcc.GET("Vendor No.",Code) THEN BEGIN
BankSC := VendBankAcc."Bank Branch No.";
BankAcc := VendBankAcc."Bank Account No.";
END;
END;0 -
Sorry my mistake there shouldn't be a second IF statement, even so it still does not work?
IF Vend."BACS Account No." <>'' THEN BEGIN
VendBankAcc.GET("Vendor No.",Code);
BankSC := VendBankAcc."Bank Branch No.";
BankAcc := VendBankAcc."Bank Account No.";
END;0 -
What is the error message?
Code is not a field specified in the table Vendor Ledger Entry. Where do you set it?"Money is likewise the greatest chance and the greatest scourge of mankind."0 -
I think your trouble is here:
VendBankAcc.GET("Vendor No.",Code);
1st, GET operates on a record's primary key, and assuming VendBankAcc is a "Bank Account" the key is "No.". If Code is a var that contains a bank acocunt No., then the line to get the bank account record would be:
VendBankAcc.GET(Code);
Wrap that in an IF/THEN to cach any error that may occur.
(Others jump in if I'm wrong here.)0 -
If you don't test for a successful GET, and the GET fails during runtime, you will receive an error. It is better to test the GET function with either an assignment to a boolean variable or by using an IF statement directly:
OK := TableRecord.GET("key 1 value","key 2 value");
IF TableRecord.GET("key 1 value","key 2 value") THEN BEGIN
// do some processing
END;0 -
Vendor Bank Account Primary Key is "Vendor No.,Code". So the code seems to be right. But I think he didn't even define any variable named "Code".
And it doesn't make sense to get a Bank Account out of a Vendor Ledger Entry. So I assume he doesn't understand the business logic of that part of NAV."Money is likewise the greatest chance and the greatest scourge of mankind."0 -
thank you all for your reply, yes this is the primary key within the VendBankAcc hence "Vendor No.",Code i have defined code as a variable. I understand that it is not within the Vend Ledg Entry what i am trying to do is get the vendor record from the vendLegEntry then from the Vendor get the BankAcc, which i am not entirely sure is possible?
I have also tried this:
Vend.GET("Vendor No.");
IF Vend."BACS Account No." <>'' THEN BEGIN
VendBankAcc.GET(Vend."No.",Vend."BACS Account No.");
BankSC := VendBankAcc."Bank Branch No.";
BankAcc := VendBankAcc."Bank Account No.";
END;0 -
I don't know "BACS Account No.", but if it contains the Code of a Bank Account of that Vendor, then it seems to be right.
Could you post your error message?"Money is likewise the greatest chance and the greatest scourge of mankind."0 -
'BACS Account No.' does contain the Code of a Bank Account of that Vendor. The report is running fine without error message now when i use the code above but it just doesn't seem to show the bank details?0
-
Its ok i placed the code in the wrong place I moved it over to the OnPreSection of the group header, Thank You all for you in put0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions