Assign value from One datatable to another

Hi,
I have two data tables

Datatable1
ID Name
1 aaa
2 bb
3 cc
4 dd
Data table 2
ID Name
rrr
tttt
ppp
77

DatTable 1 contains ID with values but Datatable2 ID has no rows

I want the Datatable2 of row("ID) = Datatable1 of CurrentRow(ID).toString

but its not giving the currect output,.

Expexted output:
Datatable 2 should be like

ID Name
1 rrr
2 tttt
3 ppp
4 77

Plz help

I dont understand in your example how the ID is matching up in Datatable 2? The names are not the same at all?

If you are just assigning consecutive numbers in the ID column of Datatable 2 then you can do it with a for each statement. For each row in Datatable2, Assign row.item("ID") = CurrentRowIndex+1 CurrentRowIndex is the variable name I made up for the output index of the for each activity

1 Like

Hi @Dave Thanks for reply

I just want the current row of datatable1 should be assigned to the IDs in datatable 2

Hi @MLT

Use for each row and create a variable for index (it is in property of for each row variable name - index)

And inside for each row put assign,

Datatable2.rows(index).item(0) = row(0).tostring

It will assign 1st row is of datatable1 to 1st row id of datatable2 and so on

so give a try on:

for each row - use the index output from this acivity (varname: idx) and loop over dt1
use an assign dt2.Rows(idx)(0) = row(0)

Hi i already tried this one

error

but it throws error : Assign: There is no row at position 3.

@ppr @prasath_S

just check if dt2 has the same rowcount as dt1

For this to work both datatables should have same number ot rows…

is there any way if we could do the same, if the row count b/w 2 datables are not same?

Put an if condition inside the for each row and condition will be,

Cint(K) <= Cint(dt1.rows.count.tostring)

And then put the assign inside then of if activity… thanks

thanks @prasath_S but no luck i throws the same error
“message”: “Assign: There is no row at position 1.”,

Can you please share the workflow screenshots please…