how to call a field by fieldref

nightrodnightrod Member Posts: 68
Hi,

How can you call a field by reference.

in a table there are 100 fields called
import01
import02
import03
..
import99

in a report i want to do as followes

i := 1

repeat
get the value of field(import + i);
Run a function;

write to field (import + i);
i = i+1;
until i = 99;

i try using the fieldref and recordref but cant figure out how to do it.
can someone help get started with this?
thanks!

Comments

  • matttraxmatttrax Member Posts: 2,309
    Have you searched the forum? There are some excellent examples in other posts.
  • nightrodnightrod Member Posts: 68
    yes i did but couldnt find what i need.
  • rmpatel22rmpatel22 Member Posts: 80
    I think its not possible.

    I tried to do this thing for one report, I tried all options, but no luck.
    Rakesh Patel
    Navision Developer
  • reijermolenaarreijermolenaar Member Posts: 256
    Hi nightrod,

    You can use the field table to get the fieldnumber and use this to retrieve the fieldref.
    YourTable.FINDFIRST;
    RecRef.GETTABLE(YourTable);
    
    REPEAT
    
      i += 1;
    
      Fld.SETRANGE(TableNo, DATABASE::"Your Table");
      Fld.SETRANGE(Fld.FieldName, 'import' + FORMAT(i));
      Fld.FINDFIRST;
    
      FldRef := RecRef.FIELD(Fld."No.");
      MESSAGE(Fld.FieldName + ': ' + FORMAT(FldRef.VALUE));
    
    UNTIL i = 99;
    
    Reijer Molenaar
    Object Manager
  • nightrodnightrod Member Posts: 68
    Hi Reijer,

    This works great. \:D/
    Thanks a lot =D>

    Nightrod
  • rmpatel22rmpatel22 Member Posts: 80
    Thanks Reijer

    This code can resolve my report problem also.
    Rakesh Patel
    Navision Developer
  • reijermolenaarreijermolenaar Member Posts: 256
    you're welcome!
    Reijer Molenaar
    Object Manager
Sign In or Register to comment.