Column Does not belong to table when it does

I am getting an error that says a coulmn does not belong to the data table. However, when I look at the data table variable it does.

It only started happening when I used the Invoke Method SetOrdinal activity to move a different column in the dt. If I do not use that activity and leave the columns as they are from the beginning, I do not get the error. I have tested multiple things and it always errors on the last column in the dt claiming it does not belong to the table (no matter which column I’m trying to call, if it’s last in the dt, it can’t find it).

Like I said, without the SetOrdinal everything works fine.

Does someone know what might be happening?

  • set a breakpoint on a location, once datatable exists and is populated
  • debug and get paused
  • type into the immediate panel: YourDataTableVariableName.Columns

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Are the column names within your expectations (check for spaces at start/end as well)?

Hi @kasey.betts

Check below post for Ordinal

Also, you can debug, linebyline to identify the issue

Hope this may helps you

Thanks,
Srini

Can you debug and check even if any column has having the space

it will show the same error ‘Column Does not belong to table when it does’

Cheers… @kasey.betts

Hi! Such a simple thing! yes there is space after the column name.

This is what I am using in_DataTable.Rows(0).Item(“Supporting Document Title”).ToString

How do I account for the unknown amount of space if it is there?

when there is a risk that it can happen just do some cleansing

  • For each Activity | item in YourDataTableVar.Clone.Columns | TypeArgument: DataColumn
    • Assign Activity:
      YourDataTableVar.Columns(item.ColumnName).ColumnName = YourDataTableVar.Columns(item.ColumnName).ColumnName.Trim()

grafik

I do not have a for each activity that allows me to change the TypeArgument…
image

no problem, as in newer versions it is auto retrieved

:ambulance: :sos: [FirstAid] For Each Activity - Forcing TypeArgument - News / Vote on Tutorials - UiPath Community Forum

Are you referencing the column by index (ie CurrentRow(5)) or by name (ie CurrentRow(“Column Name”))?

Hi @kasey.betts

Without query you can try with activity for each

  1. For each -condition = datatable. Columns

    Inside loop -body

Take assign activity

LHS
currentitem.Columname

RHS

currentitem.Columname.trim

It will remove all the columns if it os having the spaces

Hi @kasey.betts

For the reference you can see attached screenshots


Cheers…

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