get a record based on two values

olaf
Member Posts: 5
Hallo,
I need to select a value from a database with getRecord. The problem is, that I have to select a warehouse code from the report header to use this code to select later in the line the right sku to get a record identified with the item number.
this could be the code to get the Record:
how can place the value for the SKU?
I need to select a value from a database with getRecord. The problem is, that I have to select a warehouse code from the report header to use this code to select later in the line the right sku to get a record identified with the item number.
this could be the code to get the Record:
IF getLocation.GET ("Item No.") THEN ...
how can place the value for the SKU?
0
Comments
-
Maybe you should check the PrimaryKey of the record you wnat to retrieve and then decide whether to use rec.GET or rec.FIND function.
And of course read carefully help for both functions (and some more also). Then you will get the idea.®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
Hallo Robert,
never used rec.FIND before, i will give it a try.
The problem is what i see is, I got a stock keeping code from the header. then in the row i have to select a location based on an article number and the stock keeping code from the haeder. I will keep you informed tomorrow...0 -
GET() only works if you give it the parameters of the primary key. However, you can use FIND('-') to get a record. Many times you can narrow a search down to one record using FIND, even though it is capable of returning multiple records that meet the search criteria. You establish the criteria by using SETRANGE and SETFILTER on the table variable that calls FIND. Hope this helps.
hj0 -
Hallo,
Thank you all for the help...
The example for FIND in the manual (ver. 3.10a) is a little strange (not really about the find function).
Maybe someone can post a short example about how to use the function?0 -
CLEAR(AEICheckSalesLine);
JECheckSalesLine.RESET;
JECheckSalesLine.INIT;
JECheckSalesLine.SETRANGE(JECheckSalesLine."Document Type","Document Type");
JECheckSalesLine.SETRANGE(JECheckSalesLine."Document No.","Document No.");
JECheckSalesLine.SETFILTER(JECheckSalesLine."Shortcut Dimension 1 Code",'<>%1','');
IF JECheckSalesLine.FIND('-') THEN BEGIN
This example shows how to use a combination of SETRANGE and SETFILTER to narrow down the search.
The rule I follow is to use GET if I have all of the primary key information and to use FIND if I do not have the full data of the primary key.
Hope this helps.
j0 -
One more tip which is an absolute necessity if you are using SQL backend:
ALWAYS before setting ranges use a setcurrentkey. AS MUCH AS POSSIBLE the key you use should contain the fields you are sorting by, and the set ranges should be in the same order as the fields in the key.
If you do not use a SETCURRENTKEY Navision will assume you want to use the primary key, which if you are doing a FIND should really not be the best key at all...
JECheckSalesLine.RESET;
JECheckSalesLine.INIT;
JECheckSalesLine.SETCURRENTKEY("Document Type", "Document No.", "Shortcut Dimension 1 Code");
JECheckSalesLine.SETRANGE(JECheckSalesLine."Document Type","Document Type");
JECheckSalesLine.SETRANGE(JECheckSalesLine."Document No.","Document No.");
JECheckSalesLine.SETFILTER(JECheckSalesLine."Shortcut Dimension 1 Code",'<>%1','');
IF JECheckSalesLine.FIND('-') THEN BEGIN
Take it from someone who has spent time re-writing posting routines to make them faster...
-a0 -
An excellent point. It made me rewrite my routine. Thanks.0
-
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