I have a problem with FieldRef.RELATION.
I want to know, if a Field has a relation to another table. Therefore I use the FldRef.RELATION to find out the Table No.
If the field has a relation, all works fine. But if there is no relation, the fin.exe crashes.
I use 3.70 incl. HF12 (newest Runtime).
What's wrong?
RecRef.GETTABLE(MyTable);
FldRef := RecRef.FIELD("Field No.");
IF FldRef.RELATION <> 0 THEN BEGIN // <-- fin.exe crashes here if RELATION is 0
[...]
END;
Comments
You should post it on the MBS bug report system and hope they will fix it.
If it was hard to write, it should be hard to understand."
I have already posted this in the partnersource but I expected that anybody have a workaround for this issue.
If anybody of you has further informations (or a workaround) to this, please let me know about this. (If I have news, I will post them here.)
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I have some cases where the RelationTableNo is empty but the FldRef.RELATION has a value <> 0.
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
This bug is old, no response from MBS... hmmm, this will be problem, sorry, cannot help you... :?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Today, I got the following answer from the Support: In fact, this doesn't help me, but it is a ray of hope.
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
I'm not sure but please keep it in mind. I think the relation field in the "field" table is not always correct. I think.... (I THINK) is ofter not filled or 0 when there should be a value.
Just check it please!
If it was hard to write, it should be hard to understand."
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
If it was hard to write, it should be hard to understand."
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
I has now everything tries out you comes simply not to the TableRelation reliably ran. This problem exists however already starting from the Financials Versions. The problem is which you over the table Field the TableRelation sees, but only if on the TableRelation no filter is. (here you could look at times the field Base Unit of Measure in the article, you no TableRelation there will unfortunately be). You come however neither over the Fieldref functionality nor over the Rec. TableRelation to the TableRelation ran.
Ooooh wait... It's English :shock:
If it was hard to write, it should be hard to understand."
...
Field.GET(RecRef.NUMBER,FieldRef.NUMBER);
IF Field.RelationTableNo <> 0 THEN
MESSAGE('Field %1 has relation to table %2, field %3',Field."Field Caption",Field.RelationTableNo,Field.RelationFieldNo);
...
Field : Record 2000000041
This only works if the property TableRelation of the field has no condition or any other filter.
So, you cannot use this workaround if you use RecordRef / FieldRef.
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
If you read previous messages, you can see, that Tab. Field is not solution... 8)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.