0

I don't know whether any out there uses Navision?! but we've recently been lumbered with it and I'm trying to pass a field name dynamically to a function.

Instead of

ModelRec.SETCURRENTKEY(ModelRec.Transmission);

I want to do something like ...

ModelRec.SETCURRENTKEY(ModelRec("FieldName"));

where the string FieldName = "Transmission"

Can anyone point me in the right direction please?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Andy Clarke
  • 3,234
  • 5
  • 39
  • 66

2 Answers2

1

I think you need to write a little more code. In you function, you can say

CASE varFieldname Of
  Rec.FIELDNAME(FieldName1):
    Rec.SETCURRENTKEY(Fieldset1);
  Rec.FIELDNAME(FieldName2):
    Rec.SETCURRENTKEY(Fieldset2);
END;
0

If I understand correctly, you can use: Record.FIELDCAPTION(Field). This will return the name of your field.

Cosmin
  • 21,216
  • 5
  • 45
  • 60
Knutov
  • 13
  • 2