how to get the data of some fields of a datasource by the id of the field ?

Hi there !

first of all, sorry if the question was already asked I did not find any suitable answer :confused:

here is my problem. I have one table called Salesplan that have 26+fields. among thoses fields are planning for prodution for the 12 month of year and fields for the real producion for the same 12 months. in other words I have

Salesplan.pl_m1 , salesplan.pl_m2 , salesplan.pl_m… , salesplan.pl_m12 , salesplan.re_m1, …, salesplan.re_m12

my goal is to fill a table of 2 rows and 12 columns with one loop(on the column) and

table.cell(1,col).data( #some kind of expression I can build to get my 12 planned month fields#)

and table.cell(2,col).data( #some kind of expression I can build to get my 12 realized month fields#)

in other word is this some kind of function (like the =indirect("") in excell )that allow my to define dynamicaly the field or th table I want to read the data from ?

thank you very much in advance.

You can use RecordRef and FieldRef to dynamically refer to tables and fields. Search the forums for those and see if they will solve your issue.

thank you Matt ! you almost saved my day :slight_smile:

unfortunately, it seems that recordref and fieldref are navision based only :confused:

And, of course (otherwise it’s not funny) I’m working with AX 2009

Hi Frederic,

I have moved this thread to the AX forum where you hopely get an answer

thank you Dave !

I didn’t notice there were different forum, sorry !

It was so simple …

DictTable dt = new DictTable(tablenum(mytable));


for (col = 2; col <= 13; col++)


pl =((col >10)? “PL_M”:“PL_M0”)+ int2str(col-1); // build the name of the field witha regular expression

table.cell(col,row).data(mytable.(dt.fieldName2Id(pl))); // mytable.(field_id) return the data