I’m trying to do a Lookup Data Table activity but where the Data Table name is a variable. The activity is inside a loop and the lookup will occur in one of many possible tables. When I put in a variable to the Data Table field i’m told with an error that the input must be a datatable and not a string. Does anyone know how to resolve?
Use the Assign activity to create a variable that represents the DataTable you want to perform the lookup on.
Inside the Assign activity, use the DataTable variable with the AsEnumerable method to specify the DataTable’s name.
Suppose you have a DataTable name stored in a variable called DataTableName , and you want to perform a lookup in that DataTable:
Assign DataTableVariable = If(DirectCast(Variables(DataTableName), DataTable), New DataTable())
You can’t do this in UiPath. You can’t have a variable name stored in another variable. What you need is a dictionary (of string, datatable). Put all your datatables in with the datatable name as the dictionary key. Now you can get the datatable you want using yourDictVar(temp1)