I have to save invoices in a program from an excel file. Invoices can have 1 or more items. If there are multiple items, I have several excel rows with the same invoice number.
I have made an activity FOR EACH to read each invoice and in the body I need a loop. As long as the invoice number is the same, the items must be recorded within the same invoice.
I can’t get the while loop to work properly.
Maybe someone knows how to fix it. Thank you!!
@ROSARIO_JIMENEZ_MARTINEZ
Welcome to the forum
We would suggest to group the data as described here (NON-Linq / LINQ Approach)
Then loop over the group and process its members as needed
Welcome to UiPath Community!
Follow the below steps:
- Declare a variable to hold
invoice
value - Use
FOR EACH
check ifInvoice
variable empty or not. If empty, assign current iterating invoice toInvoice
variable. If not empty, Check ifInvoice
variable is same as current iteration invoice. If same record as same invoice else assign current iterating invoice toInvoice
variable
Hope this will help.
Thanks,
Ashok
There’s no need for a while loop. You just need a variable that keeps track of the previous invoice number and then compare it with the current invoice number in the For Each Row loop.
If-condition: CurrentRow("Num_Invoice").ToString.Equals(previousInvoice)
Thank you very much, you are right, this is the best way to solve my problem. Just one thing, the first row compares with the table header. Is there any way to recognize that it is the first row?
@ROSARIO_JIMENEZ_MARTINEZ while reading the excel with Read Range
checkbox the property AddHeaders
this will add first row as header and while iterating it will not iterate. Only data rows will be iterated.
Perfect, thank you!!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.