adext
October 13, 2023, 4:47pm
1
Hello
I have a datatable of shipping and corresponding order numbers as well as an empty column final num
Order, Shipping,FinalNum
1234, 552455,
1234, 9935399,
5678, 003500,
I convert this to a dictionary where I now have the orders that have multiple shipping numbers because i need to process them together
for ex: {“1234”,{“552455”,“9935399”}…}
after the processing, i will get a final num per order and i need to update the table accordingly.
So for example
Order, Shipping,FinalNum
1234, 552455, 555
1234, 9935399, 555
5678, 003500, 777
Now, how can i update my datatable each time in the following loop, right after the last workflow (has the finalnumber in output)
so for example my order is “1234” and ShippingsArray is {“552455”,“9935399”}
I have thought about using lookup but is there anything lighter ?
Thanks a lot
supriya117
(Supriya Allada)
October 13, 2023, 5:06pm
2
Hi @adext
Try this:
For Each item in orderToShippingDictionary
Assign finalNumber = 677 (Get the final number for the current order here)
If row("Order").ToString() = item.Key
Assign row("FinalNum") = finalNumber
1 Like
Yoichi
(Yoichi)
October 14, 2023, 1:29am
3
Hi,
I think it’s better to have the dictionary including datarow in advance.
For example, using the following expression.
dict = dt.AsEnumerable.GroupBy(Function(r) r("Order").ToString).ToDictionary(Function(g) g.Key,Function(g) Tuple.Create(g.Select(Function(r) r("Shipping").ToString).ToArray(),g.Select(Function(r) r).ToArray))
This way we can easily write to the finalnum to datatable just after calculated, in the loop.
Can you try the following sample?
Sample
Sample20231014-1aL.zip (3.4 KB)
Regards,
2 Likes
adext
October 14, 2023, 3:16pm
4
hello Yoichi,
thank you for always coming with helpful suggestions!
to give a bit more info, i am trying to use this datatable to trace my progress in case of retry, here is the resume: Making a custom retry
In the end I decided to use a datatable + all the other columns. so to be more precise, my datatable would actually have more columns. so something like this
Order, Shipping,FinalNum, step2, step3, …
1234, 552455,
1234, 9935399,
5678, 003500,
will this solution still work? should i replace the whole “tracing” datatable with a dictionary in this case?
Anil_G
(Anil Gorthi)
October 14, 2023, 4:59pm
5
@adext
To update multiple rows at the same time…you can use the following in the invoke code activity with dt as the in/out argument and pass the datatable
dt.AsEnumerable.Where(function(x) x("Order").ToString.Equals(OrderNumberVaraible)).ToList.ForEach(sub(r) r("FinalNum") = FinalNumberVariable)
Here replace orderNumebrVariable and FinalNumberVariable with actual values
cheers
1 Like
Anil_G
(Anil Gorthi)
October 15, 2023, 2:46am
8
@adext
Glad it helped you.
Can you please close the topic if resolved
Forum FAQ - How to mark a post as a solution
This document is part of our beginners guide .
This article will teach you how to properly mark a post as a solution.
We were closely following our last UiPath Forum feedback round! topic and carefully extracted all the bits of feedback that was provided. As such, we would like to tackle the topic of solutions on our Forum and how to properly use them.
When is the topic resolved?
The topic can be considered resolved when the topic author has fo…
Cheers
system
(system)
Closed
April 25, 2024, 11:41am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.