Assign - Change Column Name: Cannot create an L-value from the given expression with property 'ColumnName' because the target object is null

Hi,

I was trying to change the column name in the DataTable from Debit(Withdrawal) to Debit using the Assign - Change Name step:

To: ItemDT.Columns(“Debit(Withdrawal)”).ColumnName
Value: “Debit”

I get the following error:

Assign - Change Column Name: Cannot create an L-value from the given expression with property ‘ColumnName’ because the target object is null.

Please let me know what the issue is.

Thanks!

@chenghuang
Welcome to the forum

IN your case debugging anch check if Datatable / Column is really null and find out why would be the best next step. Is “Debit(Withdrawal)” really the Coumnname. Otherwise you can also try to use the columnindex instead.

1 Like

AS @ppr said, run in debug mode and when you get an error, in the variable screen on the left, check the ItemDT variable, to see if it actually has that column.

Sometimes debug mode can be a little slow, so another way to check it, would be adding some “Write to CSV” activities, in different stages of the workflow. Then you can review them and see what is happening with that column.

Also, check and make sure that the column name in your reference matches perfectly to the one in the datatable.

Please advise how you use columnindex.

Lets assume you want e.g to deal with the third column:
ItemDT.Columns(2).ColumnName

1 Like

Got it! Thanks!

@chenghuang
Okay perfect so it is working now? If then, so just flag the solving post.

1 Like

Problem solved! Thanks!

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