Alternative to using 10+ assign activities

Hi there, does anyone know a more efficient method to store values into variables from Excel. Currently, I’m using 10+ assign activities to store values into my 10+ variables, and I find it possible that there are better alternatives out there, but I don’t know what. Does anyone have any recommendations? These assign activities are used in a for each loop to loop each row in the Excel sheet and to get the values from each column based on it column name.

Hi,

I recommend to use Dictionary type variable like Config of Re-Framework

Let’s assume we have the following worksheet.
image

Next use ReadRange activity and get the table as DataTable (Let’s say dt)

Then we can get Dictionary as the following.

dict = dt.AsEnumerable.ToDictionary(Function(r) r("name").ToString, Function(r) r("value").ToString)

Note: dict is Dictionary<string,string> type

Finally we can get each value as the following.

dict("First")

This returns John

dict("Age")

This returns 32

Regards,

2 Likes

Hello @farl_tiong With the above suggestion from @Yoichi , you don’t have to use assign activity or variable to hold the value as the Dictionary variable to holding all needed data.

You don’t have to create variables to store the values. You can just reference the loop row with CurrentRow:

image

I used a Log Message activity as an example but you can use that same CurrentRow expression in any activity or expression.

Hi @farl_tiong

In For Each Loop

you can simply use and pass value as without storing and creating any variables in assign activity.

CurrentRow(“ColumnName”).ToString

Cheers!!

Hi @farl_tiong ,

You do not need use assign you can use the value directly by currentRow reference shared by @postwick else the use can utilize the method suggested by @Yoichi .
Even after that you if required you can multi assign activity to multiple assigns.

cheers