Table relation

tompynationtompynation Member Posts: 398
Hi,

When you go to the properties of textbox on a form you have to possibility to add a table relation...

"Product Group".Code WHERE (Item Category Code=FILTER(GV_ARTICLECATEGORY))

Is it possible that this table relation refers gets filtered by a global variable?

The bold is my global variable, but when i try to use the lookup now on the form i got following error:

A value in the filter 'GV_ARTICLECATEGORY' in the Item Category Code field in the Product Group table is too long for the field type.

Type: Code10


My global variable used in the filter is a code of length 10... but it isnt using the value of the Global Variable. It's just trying to use the name of the global variable

Answers

  • kapamaroukapamarou Member Posts: 1,152
    If you want to use your variable then you'll need to do it by code in the OnLookup trigger...
  • DenSterDenSter Member Posts: 8,304
    Unfortunately, in a table relationship you can't define a filter with a global variable, only on the value of another field, or a constant.

    Table relationships should not be define on a form level anyway, and lookup code should also not be programmed on the form, unless it is a situation that is unique for that particular form. Generally speaking, when you define a table relationship, it is on a table level, and the same relationship should exist on every form for that table. If you define the relationship on form 1, then form 2 will not have the same relationship, and you can have bad results. now if the relationship is set on a table level, it will behave the same way on every form, without having to change any of them.

    What is important to know, is that as soon as you add any local variables, or any C/AL code (even comment lines, even a blank line with nothing on it) in the assistedit or lookup triggers on the form, that breaks the relationship set in the table.
Sign In or Register to comment.