Assign Tool Clarification

Dear Community,

I would like to ask what is the meaning or functions for the formula - dtData.Rows(iCounter)(“Invoice Number”).ToString.

This is extracted from the screenshot below for reference.
image

Many thanks in advance

Hello @SH_94

Below is the explanation in very basic form :slight_smile:

DtData is a DataTable variable that contains data in a row and column format just like excel data sheet.

DtData.Rows property enables us to access a specified row.

ICounter is another integer variable that contains a row index or position of the row.

So when accessing a value in a datatable, we need to specify the row number and the column name to locate the cell.

dtData.Rows(iCounter)(“Invoice Number”).ToString

As explained above, now if we look at the formula,
It is trying to get the value from dtData of the row index specified by iCounter variable, and of column invoice number…

Lastly, the extracted value is converted into a string using the ToString command and assigned it to the variable in left side of assign activity.

Hope this helps…

Hi @SH_94,

dtData.Rows(iCounter)(“Invoice Number”).ToString

dtData is a datatable with n number of rows

.rows is a method which takes index as row and column as index or column name as input

iCounter in this case is the variable which is of type int and acts as the index to rows method

“InvoiceNumber” is the name of the column

.ToString converts the resulting value to a type string.

This same query can also have been written alternatively ways like

dtData.Rows(iCounter).Item(“Invoice Number”).ToString
Or

dtData.Rows(iCounter)(iCollumnIndex).ToString

Hope this helps clear your doubts.

Dear @ Lahiru.Fernando,

Thank you for the prompt response.

May i know what will be the impact if the " Icounter" being removed? I try to understand the formula " Icounter" role played in this case.

If you remove the iCounter you will not be able to define which row you want to access. Either you have to use a variable like iCounter or you have to hard code the row number like:
DtData.Rows(10)(“column name”)

This is only if you know which row to access. But if you want to loop through all the rows in a data table you can simply use a For Each Row activity

Dear @Lahiru.Fernando ,

Thanks a lot for the explanation. It is clear now

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.