🚑 🆘 [FirstAid] For Each Activity - Forcing TypeArgument

This FirstAid Tutorial will describe how the auto calculated typeargument of a for each activity can be forced


In newer versions, the TypeArgument of the For each activity is automatically derived and is no longer offered for manual configuration

Depending on different combinations of

  • UiPath Studio version
  • Selected project compatibility (Legacy, Windows…)
  • UiPath.System.Activities version
  • Use of variable vs. code statement

:no_entry: the following behavior can occur:

  • The TypeArgument is assumed to be of the data type of Object / non-Expected data type
  • BUT should be a different data type.


The derived and used Datatype can be checked on the property panel:


When rewriting the part where the List of items is passed, the involved datatype can be forced

Text related

Regex MatchCollection
Before Regex.Matches(strText, strPattern)
Targeted DataType Match
After Regex.Matches(strText, strPattern).Cast(of Match)

JSON related

JObject Property Value
Before myJobject(“data”)
Targeted DataType Newtonsoft.Linq.JObject
After myJobject(“data”).Values(Of JObject)
Comment “data” property value will be returned as a series of JObject

Datatable / DataTableSet related

DataSet DataTable
Before myDataSet.Tables
Targeted DataType System.Data.DataTable
After myDataSet.Tables.Cast(Of DataTable)

About the FirstAid Series

The first aid series offers various instructions on how to tackle a difficulty with the first steps


For questions on your specific case open a new topic and get individual support