HI, That you in advance for the help here. I am currently building an automation and i am stuc not knowing how to proceed. I have a DataTable that essentially looks like this
It is a list of orders . The way the table is structures as you can see is that the order number is repeated in each row until the line items on the order are done and the next order starts.
How to i retrieve the information pertaining to each order dynamically taking into account that there is no fixed number of line item.
In this case to process ORD-1, i will need all four line items and all four item keys and just the one order number ORD-1.
How do i dynamically assign these to variable in order to use them and process my order (taking into account that the number of item is not fixed.)
@hatakora,
Try using below query to get distinct values. (i.e Order Number)
Datatable DT = Datatable.DefaultView.Totable(true, “Order Number”)
Then loop DT and use Datatable select method to filter the rows that match with Order Number.
Use the below flow:
Main.xaml (6.5 KB)
Regards,
Senthil V.
HI thanks a lot for the fast reponse, i tested this and i can see it working but i don’t fully get the logic behind it.
If i understand correctly, with the first assign you read only the column OrderNumber and filter unique values with this: DT.DefaultView.Totable(true, “Order Number”) ?
Then you get the count of the row for each unique item found in the OrderNumber column with this filteredDT.Rows.Count.ToString?
This i really don’t get DT.Select(“[Order Number]='”+row(“Order Number”).ToString.Trim+“'”)
Also how would i be able to dynamically obtain and/or use the values of of each row and then use it for my order.
In this example i see that you sample does get a count.
Let’s say i need to see the values of each row , so 1, ABC//2, EFG//3, HIG//4, KLM
Use Debug option and set breakpoints to know the result of individual steps for better understanding.
@Senthilkumar55 i did that is how i was able to understand what you did there for the most part. I also figured out how to get the value . I can just call this to fin the exact value. This filteredrows(0).Item(1).ToString would return 1.
But my main problem remain as to how to automatically get each row dynamically. In this instance i know which index to call to get the value i need bu what happens if my next order has 10 line items. How do i make sure that information is automatically extracted no matter how many lines i get
@Senthilkumar55 the issue here is that i have an API request bult like this
<web:LineItems>
<!--Zero or more repetitions:-->
<web:OrderLineItem>
<web:PartId>49</web:PartId>
<web:Quantity>15</web:Quantity>
<!--Optional:-->
<web:Comments>Qut Added</web:Comments>
<web:Price>23.00</web:Price>
</web:DOrderLineItem>
<web:OrderLineItem>
<web:PartId>49</web:PartId>
<web:Quantity>15</web:Quantity>
<!--Optional:-->
<web:Comments>Qut Added</web:Comments>
<web:Price>23.00</web:Price>
</web:OrderLineItem>
<web:OrderLineItem>
<web:PartId>49</web:PartId>
<web:Quantity>15</web:Quantity>
<!--Optional:-->
<web:Comments>Qut Added</web:Comments>
<web:Price>23.00</web:Price>
</web:OrderLineItem>
</web:LineItems>
This means i need an automated way to add more OrderLineItems as needed . If it is one line item for the Ordernumber them IT should only add one . If there are two then add two and so on. Even if it writes it to a file that is fine, i can then read the file to make the call.
Really appreciate the help on this and sorry if i am having trouble explaining well my problem,
@Senthilkumar55 thanks a lot. I think this is it. Now i just have to figure out how i build my request from that. I appreciate the help
Cool… Happy Automation.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.