Problem with FldRef.RELATION

Timo_LässerTimo_Lässer Member Posts: 481
edited 2004-08-30 in Navision Attain
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;
Timo Lässer
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]

Comments

  • lakshmivallurulakshmivalluru Member Posts: 168
    i get the same error :(
    LR
  • eromeineromein Member Posts: 589
    It's a bug... that's what is wrong.

    You should post it on the MBS bug report system and hope they will fix it.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Timo_LässerTimo_Lässer Member Posts: 481
    Thanks for your reply.
    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.)
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • kinekine Member Posts: 12,562
    Look into table 2000000041 - Fields - there are all infos you want... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Timo_LässerTimo_Lässer Member Posts: 481
    kine wrote:
    Look into table 2000000041 - Fields - there are all infos you want... 8)
    The Field.RelationTableNo doesn't show a Table No. if it is a conditionally Relation.
    I have some cases where the RelationTableNo is empty but the FldRef.RELATION has a value <> 0.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • kinekine Member Posts: 12,562
    Sorry, i forget this situation... yes, it must be found dynamicaly and this in table Fields is not possible.

    This bug is old, no response from MBS... hmmm, this will be problem, sorry, cannot help you... :?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Timo_LässerTimo_Lässer Member Posts: 481
    kine wrote:
    no response from MBS
    This is not quite correct :wink:
    Today, I got the following answer from the Support:
    This issue will be corrected in the next release.
    In fact, this doesn't help me, but it is a ray of hope.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • eromeineromein Member Posts: 589
    guys,

    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!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Timo_LässerTimo_Lässer Member Posts: 481
    eromein wrote:
    [...] the relation field in the "field" table is not always correct. [...]
    That's what I mean. You cannot use the Field.RelationTableNo because this field is 0 if the Relation depends on a condition. :cry:
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • eromeineromein Member Posts: 589
    Ooooh sorry, just missed that post. Just a tought without checking it myself. Is there a way to find out if there is a condition defined?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Timo_LässerTimo_Lässer Member Posts: 481
    eromein wrote:
    [...] Is there a way to find out if there is a condition defined?
    I think no. :roll: (At least I don't know any way to find it out.)
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • GunnarGunnar Member Posts: 1
    edited 2004-03-16
    Moin Moin from the high north,
    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.
  • eromeineromein Member Posts: 589
    Ooooh darn, didn't realize this was a german forum. If I had known, I would have posted everything in german.

    Ooooh wait... It's English :shock:
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • krichterkrichter Member Posts: 1
    Maby not relevant any more but a possible workaround could be:

    ...

    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
  • Timo_LässerTimo_Lässer Member Posts: 481
    krichter wrote:
    Maby not relevant any more but a possible workaround could be:

    ...

    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. :cry:
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • kinekine Member Posts: 12,562
    krichter wrote:
    Maby not relevant any more but a possible workaround could be:

    ...

    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

    If you read previous messages, you can see, that Tab. Field is not solution... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.