so i’m trying to make a thing that reads excel into dt1 then merge dt2 into dt1 and remove duplicates to produce dt3, then take a row from a dt3, send some data from it in email, save the row in dt2 and then remove this row from the dt3.
I have the “add data row” function located inside “For each row” loop
Problem i have, is with this essentially a copy/paste function called “add data row”, that prevents me from copy pasting this row from dt3 into dt2. Apparently…and this is the funny part…because i’m trying to copy from one datatable to another!
I’ve read through forums and I find that this problem has been discussed on multiple occasions since 2016 if not earlier. I’ve tried “invoke method” solution that does not accept “Add” as a method, I’ve tried “get row item” that is now producing “TypeConverter cannot convert from System.string”- error… Every solution I find seems to be producing more errors that are very confusingly described, help articles are useless and hours are now wasted on trying
Also, I have been wondering as to why aren’t these errors noticed automatically? They are completely ignored until i run the software… that is so demoralizing after 100th try.
Here you were on the right track. The way to copy one datarow to another datatable is to use the Invoke method. But the function you used (“Add”) is the part that went wrong. In the invoke method you have to use ImportRow function to copy a datarow to the target datatable.
Try this and it will surely work!!
If this solves the issue, please mark it as the solution so it will help others as well…
Somehow when i use message box to see what has actually been added in to the datatable(as when the app ends it appends that datatable to csv, that turn out empty), I get a value containing “TableName” for each row that was correctly sent by email.
PS. So basically I have made it such that it is not producing errors anymore but it’s not doing anything else either.
PPS. I have initialized this datatable, that i’m trying to add rows into one by one, using “build data table”-activity is that bad?
Also Now I finally tried a seemingly ok code with Invoke method where i Managed to use datatable.Rows as target object and Add as method…system is complaining that the row belongs to another datatable…and assigning the row to be a new variable “bananas” produces same error. why is it so hard to do a simple action???
I guess the best option is to use the debug mode to test what is actually going on. Right click on an activity just before what you want to test and select add breakpoint. Then go back to the main.xaml and run the entire program again in debug mode. Once it reach the point you added the break point, you can execute it step by step while checking what values you have in your variables through the locale panel. I guess this is the best way to check why its not getting any data…
well, right now i’m still having a problem where this invoke method function only adds the separator commas into the csv without content…but at least that should be fixable…
But regarding your previous comment… well that is exactly the thing i’m trying to do. To this add a row into another dt to be saved into a persistent excel/csv database for comparison later on through merging and pruning…
And I am still baffled as to why is this activity with description “add row to a specified data table” is not working when you specify any other data table except for the one the row is in. That is insulting my intelligence to say that it works as intended, as it clearly does not… since 2016 if not earlier.
So I just take all the stuff you saw previously out and what i get this log that is empty’ish
PS. Also it would seem that my “if” condition gets selectively ignored too but the robot outputs all of the values into the log csv, instead of the 4 that actually should be there…
Hope you are passing argument to the invoke method with value. Try printing this value you are passing as input in parameters if it has value . The error you faced before that there is no method ImportRow for datatable.
Read range output is a datatable. I am not sure why build datatable was used. You can remove build datatable, if not needed. All three dt should be of same schema here. Try cloning dt2 and dt3 before you act on it or add/remove data.
Printing datatable.rows(0).tostring might give you a meaningful messagebox
Maybe it is more easy to use “filter datatable” and “merge datatable” instead of add…
first you filter the desired row from dt3 to dt_temp (check Keep)
second you filter the same row from dt3 to dt3 and (check remove)
now you do your mail-Thing and what-ever with dt_temp
after that, you merge dt_temp to dt2
and now you filter again dt_temp (check remove) and the datatable should be empty (or use clear datatable)
But if you add the datarows to dt2 you will have probably the same datarows in dt2 as right from the start - or not? (by merging dt2 to dt1 at the beginning)
Hey guys, Thank you for awesome support, but his issue has since become irrelevant for me as the project ended… now I finally have some time to study the essentials too (7 lessons till done )
My final workaround for this problem(came to me on DL day, also happens to be the day I posted here last). I solved it by removing this requirement altogether and making sure that duplicates are not shown in the source file, and so this robot became very quick, robust and simple.
All that made our submission one of the winners in an internal competition. Thank you guys! You are awesome!
In this project I was UX designer/co-author and (UIpath certified)Security specialist.