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?
ppr
(Peter Preuss)
August 22, 2023, 1:15pm
2
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)?
Srini84
(Srinivas Kadamati)
August 22, 2023, 1:17pm
3
Hi @kasey.betts
Check below post for Ordinal
How to change the ordinal or position of the DataColumn to the specified ordinal or position? Is it possible to reorder Columns? If yes, please share a sample script.
Issue/Query: How to change the ordinal or position of the DataColumn to the specified ordinal or position?
Resolution steps:
The above scenario is achievable with the help of Set Ordinal method.
Sample Excel/ DataTable Data: Consider the below data
[image]
Launch UiPath Studio and create a sample process.
Ensure to have …
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?
ppr
(Peter Preuss)
August 22, 2023, 1:42pm
6
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()
I do not have a for each activity that allows me to change the TypeArgument…
ppr
(Peter Preuss)
August 22, 2023, 2:09pm
8
postwick
(Paul Ostwick)
August 22, 2023, 2:10pm
9
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
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…
system
(system)
Closed
August 25, 2023, 2:20pm
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.