Need to find data column within a data table to use in an if statement

Hi Everyone!

I’m having an issue with the current bot I’m building that I was hoping somebody could help me with!
I have extracted a table of data from a website however I wanted to add another piece of information to the end of that data table.

I attempted to put an add column activity into my workflow to create this column however when my bot begins to iterate through I often get the error message: “Invoke Perform search workflow: A column named ‘NAME’ already belongs to this DataTable.”

I suspect that this is because my bot attempts to create this column each time it iterates which results in the recognizing of that column name. I have attempted to solve this with an ‘if’ activity wherein my bot can recognize whether or not the ‘NAME’ column exists and simply move on if the column has already been made.

I have typed ‘ExtractedDataTable.Columns(4)’ into the condition field however have been told that ‘System.Data.DataColumn cannot be converted into Boolean’
Does anyone have any suggestions for what I could do to solve my issue in this way? Unfortunately I cannot upload a copy of my workflow to help at this time.

1 Like

Buddy @nrowe
Welcome to UiPath community buddy

Firstly…the error that occurred first was due to the fact that you have already a column named Name…so you have to create a new columnname…which is not there already

Then secondly to check whether the column exists or not… under the column name NAME…
Use like this in if condition buddy
ExtractetDataTable.Columns(4).ColumnName.ToString.Equals(“Name”)
This would check whether the columnname is Name or not…if not you can create a column with add data column in ELSE part…

Hope this would help you buddy
Kindly try this and let know whether this works or not buddy
Cheers @nrowe

1 Like

Did that work buddy @nrowe

I was able to use a slightly modified version of what you used, but yes it was helpful thank you!

1 Like

Thats fantastic
If this gets resolved kindly make a solution buddy that could help others as well
Cheers @nrowe