views:

89

answers:

2

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?

A: 

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

Nuchl

Nuchl
A: 

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;