cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Infotable access with indexing both rows and columns

ZbigniewK
9-Granite

Infotable access with indexing both rows and columns

I'm looking for solution, where I can access value of property by 2 indexes: i for rows, j for columns. 

Something like myValue = myInfotable.rows[i].columns[j]

Also could use solution like

columnName = myInfotable.fields[j].name;

myValue = myInfotable.rows[i][ColumnName];

 

Generally, I have bulk load of data, some auxiliary infotable and destination datatable.
I have a loop where I read rows of destination table, call service to read data acc. to row from destination table. Inside loop to read  received data record after record, and inside this - loop to check if datas coresspond with rows of aux table, If data fits - increase value in destination infotable, in actual row of it - but column number of destination table depends on row of auxiliary table. 

Something like: (columnA, columnB, columnC are just direct name of column)

for (i == 0; i<dest.getRowsCount();i++) {

   {data = myService (dest.rows[i].columnC);

    for (j == 0; j<data.getRowsCount();j++) {

           for (k==0; k< aux.getRowsCount();k++) {

                   if (data.rows[j].columnA==aux.rows[k].columnB) {

                        dest.rows[i].column[k] = dest.rows[i].column[k]+1;

                   }

           }

    }

}

 

Of course, I could do it with if's like, but I don't like such amounts of ifs. 

for (i == 0; i<dest.getRowsCount();i++) {

   {data = myService (dest.rows[i].columnC);

    for (j == 0; j<data.getRowsCount();j++) {

      if (data.rows[j] == aux.rows[0].columnA) {dest.rows[i].columnD++};
      if (data.rows[j] == aux.rows[1].columnA) {dest.rows[i].columnE++};

      if (data.rows[j] == aux.rows[2].columnA) {dest.rows[i].columnF++}

      if (data.rows[j] == aux.rows[3].columnA) {dest.rows[i].columnG++};

...

 

3 REPLIES 3
slangley
23-Emerald II
(To:ZbigniewK)

Hi @ZbigniewK.

 

We're not totally sure what you need to do, but assuming you only want to receive one cell of your infotable, the following code would retrieve the first row on an infotable called infotableName and only return the name field from the first row:

 

result = infotableName[0].name;

 

Is this what you're trying to do?  If you have other questions, please let us know.

 

Regards.

 

--Sharon

Yes, but no.

Yes, I want to access cells of infotable.

No, because I do not know name of column. I know it's column number j, where j is integer.  
So, if I would like to use proposed method, I would need a script which will take j as argument, and will answer me what name has column number j. 

Hi @ZbigniewK 

 

Please refer to this one - javascript - Retrieving a property of a JSON object by index? - Stack Overflow

 

If you want to get a column name from InfoTable (JSON Object) using index. You need to make a separate array with column names and you can use it in the loop.

 

/VR

Top Tags