Change for each new modern design

How to change the datatype of for each in modern design ?
By default it is object and I am unable to convert it to datatable
image

1 Like

You don’t change it, it’s automatic now. You have to fill in the “List of items” field and then it determines what the TypeObject is. The TypeObject isn’t the datatype of the source object, it’s the datatype of the things within it. For example, if the source object is List(of String) then the TypeObject is string. It determines the datatype of currentItem.

But if you’re trying to loop through a datatable you should use For Each Row in Datatable, not For Each.

trying to loop through datatset

Then this is your answer.

what should be the syantaxz? for each row in datatset.table ? but it is not working

You are trying to use For Each. That’s the wrong activity. The correct activity is For Each Row in Data Table:

https://docs.uipath.com/activities/other/latest/workflow/for-each-row

You should go through all the UiPath Academy courses to learn how to write automations. Here is one specifically for what you’re trying to do.

when looping over the data tables from the dataset:
For each activtiy: YourDataSetVar.Tables

when looping over a data table from a dataset:
For each row in datatable activity: YourDataSetVar.Tables(#)
#-the zero based index OR tablename, when properly set

Hi @Ritaman_Baral

To iterate the datatable. We have another activity called for each row in datatable activity which is used to iterate the datatable.

This for each is not used to iterate the datatable, it is used to iterate the Collection datatypes.

Hope it helps!!

In latest vesion,We heard that For Each Activity has no TypeArgument Property and it will Automatically Pick TypeArgument. But sometimes it is not working as we excpect. Then, what is the Solution ?

𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 :
𝐂𝐚𝐬𝐞 𝟏 : CType(Value_Object,Target_Datatype)

𝐂𝐚𝐬𝐞 𝟐 : DirectCast(Value_Object,Target_Datatype)

For Clear Information, You can see the below image.

or if u want like before you downgrade the version

appending any suffix which will specify the details. The Post was about DataSets and not JSON.

For JSON we would do e.g.: yourJObject(“data”).Values(Of JObject). So its about correct retrieval which would make the casting obsolete or changed

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