In an automation I am working on, a problem occurred because I was using ArrayRow in the Add Data Row activity. The issue is that ArrayRow relies on column position instead of column name. In this automation, the datatable is created by reading a JSON definition of the datatable from an asset, and using this expression to convert it into an actual datatable:
JsonConvert.DeserializeObject(of datatable)(str_FilesArrayDefinition).Clone
The problem occurred because I updated the column definition asset to add a new column, which slid the rest of the columns back by one position. Now existing automations are putting the values into the wrong columns.
In order to use Add Data Row by column name instead of column position:
-
Create a System.Data.DataRow variable
-
Initialize NewDataRow using the .NewRow expression. This copies the datatable’s schema to the datarow object
-
Assign values to NewDataRow by column name
-
Add NewDataRow to the datatable using Add Data Row
Now future changes to the definition asset will not affect existing automations, because they’re using column name instead of position to assign the values to the datatable row.