Add data collumn DuplicateNameException

Hello guys. I have a problem with Add Data Column. I have a data table like this:


Robot takes the first row in “URL” pastes it to google, takes out data that is needed and then adds data collumn to that data table with the default value as “CurrentRow.item(“KODAS”).ToString”. The add data column activity is in for each row in that data table that i have attatched a screen shot above. But I get this error:

Anyone knows how can this be resolved?

EDIT: The first try is always good, but when the Ui goes to the next url “Because of each row in dt” activity, it throws this error

You need to move the “Add Data Column” activity outside of the loop: the robot must execute this activity only once. In the loop, you only have to set the value in the data row.

But why? I have a robot that basically does the same thing, instead this one should write not the first collumns current row, but the second

Then I’m not following your issue. Can you share the xaml file?

The code looks like this:


The data table that is used by “for each row in data table” activity looks like this:

URL column is needed to go to urls where the needed table extraction happens. Then when it does happen, “add data collumn” activity adds a collumn named “Kodas” to the newly gotten data table and it has a default value of “CurrentRow.item(“KODAS”).ToString”. The first url gets scrapped how I want it to, but when it comes to second, it gives me an exception that I have attatched above.

The xaml
RRR modeliai.7z (2.3 MB)

Thanks! I can’t open the file though, can you send it as .zip?
Also, can you check if the scope of the data table you’re creating at each iteration only exists within the loop, and not outside? If you’re reusing the same variable at each loop (with a larger scope), that might be your problem
image

was also forced to review XAML at XML level
Maybe add Data Column and populating the data column values is mixing up

we would recommend to debug and inspect the variables by using the different debugging panels

A defensive approach could look like
If: YourDataTableVar.Columns.Contains(“Koda”)
Then: YourDataTableVar.Columns(“Koda”).DefaultValue = …
Else: Add Data Column

BTW. we avoid to use ClassNames / keywords… in our variable names. so DataTable as Variable name is not recommended

Thanks guys for the responses. I will look into both of them and let you know tomorow

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