Why use the GET function with setup tables?

alex6789
Member Posts: 9
Why does the get function need to be used in this instance:
if not SalesReceivableSetup.get() then
SalesReceivableSetup.insert();
if SalesReceivableSetup."Order Nos." = ' ' then begin
SalesReceivableSetup."Order Nos." := CreateNoSeries();
SalesReceivableSetup.Modify();
if not SalesReceivableSetup.get() then
SalesReceivableSetup.insert();
if SalesReceivableSetup."Order Nos." = ' ' then begin
SalesReceivableSetup."Order Nos." := CreateNoSeries();
SalesReceivableSetup.Modify();
0
Best Answers
-
The statement "if not get" checks that if a record cannot be found in the setup table then it will create a new empty record (.insert). Then no matter what we know that we have fetched a record in the lines further down where we set the "Order Nos." field and modify the record. Either we have gotten (GET) the existing record in the setup table or we have created (INSERT) a new record in the table.1
-
Hi alex6789,
Why is it necessary to use the get function in this case?
If you don't do a GET, you don't position yourself on any records in the table, so you don't actually modify any values.
The GET in tables with a primary key of a single field is the equivalent of doing as many SETRANGE as fields have the primary key of other tables such as number 37, which you are doing in another part of the code.
SalesLine.SETRANGE("Document Type","Document Type");
SalesLine.SETRANGE("Document No.","Document No.");
SalesLine.SETRANGE("Attached to Line No.","Line No.");1 -
@alex6789 - That's something which also gazed my attention during my initial days, Get is used to when you want to filter directly on Primary key Value OR else we use SETRANGE. For all these setup tables we have just one record and the name of the Primary key column is Primary Key only.
By default if you will se these setup pages there's code written to check if its not blank then simply INIT INSERT, which ia actually inserting one record whose primary key value is something NULL you can say,
So that's why we simply GET which nothing as parameter and then it gets the reference for the entire columns.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/1
Answers
-
The statement "if not get" checks that if a record cannot be found in the setup table then it will create a new empty record (.insert). Then no matter what we know that we have fetched a record in the lines further down where we set the "Order Nos." field and modify the record. Either we have gotten (GET) the existing record in the setup table or we have created (INSERT) a new record in the table.1
-
Hi alex6789,
Why is it necessary to use the get function in this case?
If you don't do a GET, you don't position yourself on any records in the table, so you don't actually modify any values.
The GET in tables with a primary key of a single field is the equivalent of doing as many SETRANGE as fields have the primary key of other tables such as number 37, which you are doing in another part of the code.
SalesLine.SETRANGE("Document Type","Document Type");
SalesLine.SETRANGE("Document No.","Document No.");
SalesLine.SETRANGE("Attached to Line No.","Line No.");1 -
@alex6789 - That's something which also gazed my attention during my initial days, Get is used to when you want to filter directly on Primary key Value OR else we use SETRANGE. For all these setup tables we have just one record and the name of the Primary key column is Primary Key only.
By default if you will se these setup pages there's code written to check if its not blank then simply INIT INSERT, which ia actually inserting one record whose primary key value is something NULL you can say,
So that's why we simply GET which nothing as parameter and then it gets the reference for the entire columns.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/1
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