TableRelation and Secondary key? - help

abartonicek
Member Posts: 162
Can TableRelation property be used with secondary key?
Better to be critical then self-critical 

0
Answers
-
Not as far as I know. You give the relation to a table without any key.
Greetz
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
The reason I'm asking that is that I have two tables - Jobs and UniqueStamp.
Table UniqueStamp has No. field from Jobs table and (among others) StampNo. field.
The Primary key in table UniqueStamp is ONLY field StampNo. (StampNo. must be unique no matter what job number is used)
and I have to have TableRelation to Jobs table by No.
Any suggestions about that TableRelation?Better to be critical then self-critical0 -
You mean you want to relate to a certain field which is not part of the primary key?!
Try this:
If you're standing in the table relation-property, use F6 to specify the table relation. Enter the table no. in the field table. Then, using F6 in the "field"-field, you can choose the field the relation goes to.
This should actually work!
Regards
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
I know about that. I set the Table Relation like that but it doesn't seem to work. Maybe I'm doing something else wrong.
From Job Card I call UniqueStamp List (editable for now) where I add some Stamps but I get error Job No. "" doesn't exist.
For some reason the Job No. is unknown.
RunFormLink for UniqueStamp List is set to StampNo.=FIELD(No.)Better to be critical then self-critical0 -
The "No." field is the identifier of the Job table. You need to map the StampNo field in the Job table to the ID field in your UniqueStamp table. That should take care of filling the right values and validating the stamp number when you enter one in the Job Card.
<elaborate>
This is how I understand yur setup:
UniqueStamp table:
StampNo field, which is the primary key
[other fields]
Job table:
StampNo field, which needs to be the same data type and length as the StampNo field in the UniqueStamp table, and it has a TableRelation to the StampNo field of the UniqueStamp table
The TableRelation property would look like this:
UniqueStamp.StampNo
Since the StampNo field is the primary key, that's all you need to make this relation complete.
Now if you want to limit the uniquestamp records visible from the Job Card, you need to add a "Job No." field to the UniqueStamp table, with a relation to the "No." field of the Job table. Then, in the Job table, you can add a filter to the tablerelation to the stampno field.
</elaborate>0 -
I suggest that this is the problem:
RunFormLink for UniqueStamp List is set to StampNo.=FIELD(No.)
If you're in the job card, the no. is the job no.
If you wanna see all StampNos that belong to the current project, you need to have JobNo=FIELD(No.). Or did I missunderstand the configuration?
Greetz
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
Ok, this is the situation:
The Job table is unchanged!
Job table:
No.
[other fields]
UniqueStamp table:
StampNo. -> Primary key
No. -> table related to Job No. => Secondary key
[other fields]
Desired funcionality:
For every Job I can have some number of Stamps that are represented by their number (StampNo.)
The key is that Stamps MUST be UNIQUE (not unique for certain Job!)
Maybe it's simple problem but... :?:Better to be critical then self-critical0 -
But then you don't have a field reference but a menu point to open a new form with the stamps in it, right?
In the menu button, where you run the form "stamps", you run the form using the RunFormLink-property. This must be "Job No=FIELD(No.)" as well, because you wanna see all the entries in the UniqueStamp table, that has the actual job no (the job you're in) in the field JobNo.
Your entry (StampNo=Field(No.)) filters the UniqueStamp table in the field StampNo and expects the JobNo to be in this field. I still suggest that this is the problem!
Hope I got it now.
Regards
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
Actually, RunFormLink is No.=FIELD(No.)
The first No. is from my table and the second No. is No. from Job table.
Yes, you got it right, my post was wrong.
The StampNo=Field(No.) should write No.=FIELD(No.) because field that referes (is table related) to Job No. is called No. not StampNo. Sorry.
When I try to enter new Stamp record from Job Card I can enter StampNo but the record is filterd out from the List becouse Job No. is unknown.
My question is: From Job Card, how do I set No. field in UniqueStamp table to current Job No. automatically?
This all worked well before when I had No. and StampNo as fields in primary key of UniqueStamp table.
Then I had to make StampNo unique and.... you know the restBetter to be critical then self-critical0 -
If the field is a primary key field you get automatically the filter value in the field while entering a new line. If it's not, I would try to put
"No":=GETFILTER("No"); //This is your job no.
in the "OnNewRecord"-trigger of the form (UniqueStamp-Form). This should work. Maybe there is a better way, but this is the one that comes to my mind first.
Greetz
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
If everything worked fine before when PK was No.,StampNo.,
what should I change now when PK = StampNo. and SK = No.
Everything else is the same.
PK=primary key
SK = Secondary keyBetter to be critical then self-critical0 -
Did you try to implement the coding as I posted before? This should work well even if the (job) no. is not in the primary key any more.
Which problems did you have with the coding?
Greetz
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
Sorry, I posted before I saw yours.
It worked! =D> =D> =D>
Thanx a lot!
Could you explaine my what did I gain by setting No":=GETFILTER("No") ?
I get current filter and?
Sorry for being pain in the....Better to be critical then self-critical0 -
The function GETFILTER("No") gives you the value of the filter in the field "no." as you can see in the table filter. Therefore the code No":=GETFILTER("No") enters this value in the field "no." again. If you put this in the "OnNewRecord"-trigger the field "no." while be pre-defined with the filter, what is exactly what you we're trying to do!
It was a pleasure to help you.
Finally we figured out! =D>
Greetz
NicoleProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt0 -
Nicole,
you save the dayBetter to be critical then self-critical0
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