How to increment this expression this way in uipath studio

I want to add this expression in a column in a datatable but we increment in this way the last number ,

as you see below : ( the column Named “External_key”)

External_Key

LIMIT_20221024_00001
LIMIT_20221024_00002
LIMIT_20221024_00003
LIMIT_20221024_00004
LIMIT_20221024_00005
LIMIT_20221024_00006
LIMIT_20221024_00007
LIMIT_20221024_00008
LIMIT_20221024_00009
LIMIT_20221024_00010
LIMIT_20221024_00011
LIMIT_20221024_00012
LIMIT_20221024_00013
LIMIT_20221024_00014
LIMIT_20221024_00015
LIMIT_20221024_00016
LIMIT_20221024_00017
LIMIT_20221024_00018
LIMIT_20221024_00019
LIMIT_20221024_00020
LIMIT_20221024_00021
LIMIT_20221024_00022
LIMIT_20221024_00023
LIMIT_20221024_00024
LIMIT_20221024_00025
LIMIT_20221024_00026
LIMIT_20221024_00027
LIMIT_20221024_00028
.
.
.
.
.
LIMIT_20221024_62126
LIMIT_20221024_62127
LIMIT_20221024_62128
LIMIT_20221024_62129
LIMIT_20221024_62130
LIMIT_20221024_62131
LIMIT_20221024_62132
LIMIT_20221024_62133
LIMIT_20221024_62134
LIMIT_20221024_62135
LIMIT_20221024_62136
LIMIT_20221024_62137
LIMIT_20221024_62138
LIMIT_20221024_62139

@aya.lajili

You can Assign a String variable as strKey = “LIMIT_2021024_”
Now create a Int variable as intIndex and assign it as 1
Build a Datatable as External_Key column Name and create a Datatable variable let’s say dt_Key
Use DoWhile Loop and in the condition you can write as Index <> Your number
Inside the Dowhile you can add a Add row and In Datarow write it as
strkey + intIndex.ToString.padleft(5,CChar(“0”))

Now use Assign activity and write as intIndex = intIndex + 1

Hope this may help you

Thanks,
Srini

Hi,

If you need to create the above datatable, the following will work.

dt = Enumerable.Range(1,62139).Select(Function(i) dt.LoadDataRow({"LIMIT_20221024_"+i.ToString.PadLeft(5,"0"c)},False) ).CopyToDataTable

Sample20230509-3L.zip (2.8 KB)

Regards,

1 Like

Please , when we have a datatable that contain the column Name "Externel Key " how it will be , , because you expect that the datatable is the column ?

Hi,

Do you already have datatable which has 62139 rows and need to update each row?

Regards,

yes , i have a datatable wich has 62139 rows and i have an empty column “External Key” and i want to fulfil by incrementing this column by this expression " LIMIT_20221024_00001" , but i think there is no need to put a range " ( 1 , 62139) " because it will be incremented by default is it right ?

Hi,

Can you try the following InvokeCode?

dt.AsEnumerable.Select(Function(r,i) Tuple.Create(r,i+1)).ToList().ForEach(
Sub(t)
    t.Item1.item("External_key")="LIMIT_20221024_"+t.Item2.ToString().PadLeft(5,"0"c)
End Sub
)

Sample20230509-3Lv2.zip (3.0 KB)

Regards,

1 Like

Hi ,

Thank you a lot its working and successful :grinning:

Regards,

1 Like