I add a column to my data table.
and then I go with Invoke method, and now how do I point out that the last column in my data table that was added with the previous activity, should be moved before all of the columns so it be first on the list.
In UiPath, when you use the Add Data Column activity, the new column is by default added at the end of the DataTable. To add the new column as the first column in your DataTable, you can follow these steps:
Add Data Column:
Use the Add Data Column activity to add the new column at the end of the DataTable. Assign a default value, if necessary.
After adding the column, you can use the Assign activity to reorder the columns in the DataTable. To move the newly added column to the first position, you can use the following expression in the Assign activity:
Replace YourDataTable with the name of your DataTable and "NewColumnName" with the actual name of the column you want to move to the first position.
This expression orders the columns based on whether the column name matches the specified name. The column with the specified name will have an index of 0 and will be positioned first in the DataTable.
Here’s how you can implement this in UiPath:
Add Data Column (Add your new column at the end of the DataTable)
YourDataTable = YourDataTable.Columns.Cast(Of DataColumn)().OrderBy(Function(col) If(col.ColumnName = "NewColumnName", 0, 1)).CopyToDataTable()
After executing these steps, your new column will be the first column in the DataTable.