Display cross reference number for specific item & custo

johnsogj
Member Posts: 103
Hello, I'm creating a report that displays all items and associated information for each. One field I must display is the Cross Reference Number for customer "X" which is stored in the Item Cross Reference table. How can I code for this? Here is what I tried, but the report comes back blank in this column for all records:
Xref.SETCURRENTKEY("Item No.","Variant Code","Unit of Measure", "Cross-Reference Type No.");
Xref.SETFILTER("Cross-Reference Type No.", 'C00010');
Xref.SETFILTER("Item No.",Item."No.");
Xref.SETFILTER("Variant Code",' ');
Xref.SETFILTER("Unit of Measure", 'EA');
XNo := Xref."Cross-Reference No.";
Xref.SETCURRENTKEY("Item No.","Variant Code","Unit of Measure", "Cross-Reference Type No.");
Xref.SETFILTER("Cross-Reference Type No.", 'C00010');
Xref.SETFILTER("Item No.",Item."No.");
Xref.SETFILTER("Variant Code",' ');
Xref.SETFILTER("Unit of Measure", 'EA');
XNo := Xref."Cross-Reference No.";
0
Comments
-
Xref.SETCURRENTKEY("Item No.","Variant Code","Unit of Measure", "Cross-Reference Type No.");
Xref.SETFILTER("Cross-Reference Type No.", 'C00010');
Xref.SETFILTER("Item No.",Item."No.");
Xref.SETFILTER("Variant Code",' ');
Xref.SETFILTER("Unit of Measure", 'EA');
IF Xref.FINDFIRST THEN
XNo := Xref."Cross-Reference No.";[/b]NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger0 -
I cleaned up your code a little more:
Xref.RESET; Xref.SETCURRENTKEY("Item No.","Variant Code","Unit of Measure", "Cross-Reference Type No."); Xref.SETRANGE("Cross-Reference Type No.", 'C00010'); Xref.SETRANGE("Item No.",Item."No."); Xref.SETRANGE("Variant Code",' '); Xref.SETRANGE("Unit of Measure", 'EA'); IF Xref.FINDFIRST THEN XNo := Xref."Cross-Reference No.";
Always use RESET-SETCURRENTKEY-SETRANGE/SETFILTER. Like this everyone sees directly that at the start of the code there are NO other filters active (and it can also avoid some bugs later when someone else changes something in the object).
-Don't use SETFILTER if you can avoid it. Better use SETRANGE. On the Navision DB it can be faster then a SETFILTER, but never slower. It is more readable because the SETRANGE has a clearer syntax for filtering on 1 value or a range of values.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
thank you! it worked perfectly0
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