Table Relation to the Item Table

tompynation
Member Posts: 398
Hi,
I created a form. Added a textbox to it and created a global variable of type Code.
I added this Global Variable as source expression for my Textbox.
In the Properties of the textbox i add following table relation:
Item."Custom No." WHERE (Product Group Code=CONST(COLORMIX))
Now when i run the form and use the lookup of the textfield to select a "Custom No." i receive the error that:
The field below most be included in the table's primary key.
Field: "Custom No."
Table: Item
Why is this? Can't we create a table relation to a field that is not inside the primare key?
I created a form. Added a textbox to it and created a global variable of type Code.
I added this Global Variable as source expression for my Textbox.
In the Properties of the textbox i add following table relation:
Item."Custom No." WHERE (Product Group Code=CONST(COLORMIX))
Now when i run the form and use the lookup of the textfield to select a "Custom No." i receive the error that:
The field below most be included in the table's primary key.
Field: "Custom No."
Table: Item
Why is this? Can't we create a table relation to a field that is not inside the primare key?
0
Answers
-
Solved by adding following code to the OnLookupTrigger of the textbox:
lv_Item.RESET;
lv_Item.SETRANGE("Product Group Code",'COLORMIX');
IF FORM.RUNMODAL(31,lv_Item) = ACTION::LookupOK THEN
gv_ProductGroup := lv_Item."Sidec No.";
But still, is this some kind of bug in NAV that you cant set the same relation through the TableRelation property?0 -
But still, is this some kind of bug in NAV that you cant set the same relation through the TableRelation property?
This is not a bug - it is just the way it works. There can be MANY items whose "Custom No." field matches your criteria, not just one. But you are telling the system that the user will select ONE record, but you are not giving the system any way to identify which record needs to be selected (the only way to do this is to reference the primary key, which is what Navision is asking for).
The solution you have is the proper way to fill the field on your form.
-a0
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