How to iterate over Columns and only one row

Hii,

I Have a range of columns on which i wanted to iteration.
Also i have a row index on which i want to iterate my coumns.

But my issue is I dont know how to loop on one row and all columns.

Means ,Suppose at row 16 i want to iterate on evry column.

so how do i write logic for this.

please help

Hi @Doonline

Have a view on the thread below!

Regards

No thats not my requirement

Hi!

if you want only one row you can simple use get row item

Regards,
NaNi

I dont want row.
I have it.
only on that row i want to iterate my column

Hi @Doonline

Suppose we are assuming that creating the index variable in for each row

You need to iterate over column means

Currentrow(idx).tostring will give the result as per row index!

Regards

1 Like

Hi!

In that case try like this

DataTable.Columns(Index).ColumnName

Regards,
NaNi

This will give me the index of column

heres an example:
e.g. you have a datatable called “dt” then you assign the 16th row to a DataRow variable called “row16”

  • you can use a foreach loop, where typeArgument = “DataColumn” and values = “dt.Columns”, to loop over all the columns of that datatable,
  • to loop over the columns of “row16”, just do row16(item.ColumnName).toString on each iteration

    When i run this sequence you can see that it only prints out the column values for that particular row
    image

Sequence.xaml (10.6 KB)

@Doonline ,

You can use For each row and while loop to loop through all columns of a particular row.

First, we can get the column count of datatable.
Then, use for each row & while activity. For this purpose, I have just used a log message.

image

image

Hope this helps. Happy Automation!!!

2 Likes

iterating over all column values of a particular row we can use the itemArray of that row

YourDt.Rows(YourIndex).ItemArray - an Object array each item representing the particular column value

grafik

I think I have the same problem with him. He doesn’t have a data table present at the workflow level?

So he is iterating over a transaction item with a data type of DataRow. This DataRow he wants to iterate all over the columns of this. So we will have to think of how to iterate over with DataRow only.

hello I managed to solve my own problem. If this is also your problem, here’s what I did

I created a variable that will store my data columns, in order to achieve this create a variable with a DataColumnCollection.

use assign activity.
variable of DataColumnCollection = name of data table where your data row is coming from.Columns

So this will store all the columns available in the data table. As for me, I am working with REFramework so I used it as an argument instead ( out_ColumnNames), I also created a variable in the Main to pass the out_columnnames.

and then in the workflow you’re working with,

use a for each, set type argument to DataColumn (not datacolumncollection),

as for me
Column in in_ColumnNames

Column - will return the names of your columns
inside this transaction_item(Column) - will return the value inside

My transaction_item is of type DataRow