Change a lookup-field based on another field


Currently, I’m building a lookup-field (FieldB) and I want to show different values based on the value of another field (FieldA) on the same table.
I created a lookup-method where I added a switch-case based on the value of the other field the lookup-field depends on.

Now, let’s say the other field (FieldA) can have 3 values: A, B and C.
Whenever I create a new record, the value of FieldA is always “A” as default. When I press on the lookup-field (FieldB), I can see all the values it should show when the value of FieldA is on “A”.
But when I change the value of FieldA to “B” or “C”, the lookup-field still only shows the values for value “A”.

How can I make so the lookup always updates it’s values depending on the value of another field (in this case FieldA)?

Currently, my lookup-method on the field looks like this:

public void lookup(FormControl _formControl, str _filterStr)
DummyTable dummyTable;
FieldAValues ABCValues;

dummyTable = element.args().record();

ABCValues = dummyTable.ABCValues;

DummyTable::lookupABCValues(_formControl, ABCValues);

And my switch-case:

case ABCValues::a:
sysTableLookup = SysTableLookup::newParameters(tableNum(TableA), _ctrl);
sysTableLookup.addLookupfield(fieldNum(TableA, ItemId));
case ABCValues::b:
sysTableLookup = SysTableLookup::newParameters(tableNum(TableB), _ctrl);
sysTableLookup.addLookupfield(fieldNum(TableB, ItemId));

case ABCValues::C:
sysTableLookup = SysTableLookup::newParameters(tableNum(TableC), _ctrl);
sysTableLookup.addLookupfield(fieldNum(TableC, ItemId));


I appreciate any help


Urgh, I already found the solution myself :slight_smile: