Problems reading specific Record from a Table / Navision 4.0

aod
Member Posts: 54
I want to get an other record from the Sales Shipment Line in the Report "Delivery Note". I created a new Key containing the 3 Fields Document No., Position & Type. I created an new Global in the Report calles ShipLine. And using the Following Code:
ShipLine.setcurrentkey ("Document No.","Position","Type");
If ShipLine.Get ("Document No.","Position",Type::Item) THEN;
I get the Error Message :
"Too many Key Fields where specified, so Sales Shipment Line could not be retrieved. The number of Fields in Primary Key is 2."
What I am doing wrong ?
ShipLine.setcurrentkey ("Document No.","Position","Type");
If ShipLine.Get ("Document No.","Position",Type::Item) THEN;
I get the Error Message :
"Too many Key Fields where specified, so Sales Shipment Line could not be retrieved. The number of Fields in Primary Key is 2."
What I am doing wrong ?
0
Comments
-
GET always works with the primary key. It does not use the key you selected with SETCURRENTKEY. And the primary key of Sales Shipment Line is "Document No.,Line No.", so it expects only 2 fields.
Otherwise you need to write your code like this:ShipLine.SETCURRENTKEY("Document No.","Position","Type"); ShipLine.SETRANGE("Document No.","Document No."); ShipLine.SETRANGE(Position,Position); ShipLine.SETRANGE(Type,ShipLine.Type::Item); IF ShipLine.FIND('-') THEN;
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
Big THX for fast Answer and the very good explaination !
I will try it as soon as possible.0 -
"Get" ever use the primary key. When yoe will use an secondary key, you must use setfilter / setrange and find.
RegardsDo you make it right, it works too!0 -
garak wrote:"Get" ever use the primary key. When yoe will use an secondary key, you must use setfilter / setrange and find.
Regards
A good programming practice is:recMyRecord.RESET; recMyRecord.SETCURRENTKEY("My Key"); // even if it is the primary key recMyRecord.SETRANGE(...); recMyRecord.SETRANGE(...); recMyRecord.SETRANGE(...); recMyRecord.SETFILTER(...); // if you can't use a SETRANGE IF recMyRecord.FIND('-') THEN REPEAT UNTIL recMyRecord.NEXT = 0;
or in case you don't want to loop the records:IF recMyRecord.FIND('-') THEN ...
or even better in 4.00SP1:IF recMyRecord.FINDFIRST THEN ...
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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