Getting Error: "Assign: Exception has been thrown by the target of an invocation." in For Each Row activity

Hi everyone, I have seen several posts about this error, but none that have led me to a solution to my problem.

I have a data table with four columns, but only data in the first one (“companyName”) at the time of getting to the For Each Row loop. I am trying to add data in the second column (“website”) for each company with each passing of the For Each Row loop. See screen shots below

However, when I try to use an assign activity to do so, I get the error mentioned in the subject line of this post. The assign activity reads like: row.Item(“website”) = companyURL . companyURL is a string variable that unsurprisingly holds the company’s URL.

Any suggestions on how to solve / work around this error? Thanks!

Hello,

I don’t think you need to use Get Row Item activity in the beginning. When using For Each Row, UiPath automatically assigns row object to variable “row”. Try deleting it and run robot again.

I created a similar workflow to yours and it worked fine:

And the result:
image

@gdoyle, Can you please try row(“website”) = companyURL instead?

Hi Alisa, thank you for the quick response! I removed the Get Row Item, and you are right about me not needing it, but I still get the same error :confused: Here is my updated workflow… any suggestions?

Thank you for your quick response! Unfortunately changing the Assign activity to row(“website”) = companyURL still raises the same error…

Hi,

Quick question: do you use Build DataTable activity to create your datatable? Could you please send a screenshot of its structure?
The issue might be that the variable type of the column “website” and the value you are trying to assign are different.
Maybe try also row.Item(“website”) = companyURL.ToString

Also it could be, that companyURL is actually a null value. Try adding Message Box to display companyURL after Get Full Text just to check if companyURL has any value.

I tried the two quick fixes and has no luck… row.Item(“website”) = companyURL.ToString throws the same error and the companyURL does have the correct value.

But yes, I am using a Build Datatable activity in my Main workflow. See below:buildDataTable

Let me know if you want screenshots of anything else. Thanks again!

@gdoyle, Everything looks good to me, my only suspect is are you using correct quotation mark (“website”)? What happens if you try to print value of row(“website”).ToString using Write Line Activity (even if its blank).

Cheers

2 Likes

Bhavik my man! Turns out there was no column named “website” because of the way I was building my data table. When I loaded in the one column CSV, it deleted the 3 other columns in the data table I created in the step before.

Thanks again for the help!

Alisa, I got my issue resolved, but thank you again for your help!

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