i have a datatable which has invoices column.
i want to search invoice number and get its row index, invoice number in datatable don’t have leading zero but the problem is with invoice number which im going to search in datatable, some times it is 10409 and sometimes 00010409.
Hi @aslam_ali1 ,
Thanks for reaching out to the UiPath community.
-Initialize a DataTable: Ensure you have a DataTable loaded with your data, including the “invoice_number” column.
Input Invoice Number: Prompt the user or set a variable to input the invoice number you want to search for. This can be a string.
Remove Leading Zeros: Use a custom VB.NET expression to remove leading zeros from the input invoice number. You can use the TrimStart function to achieve this.
invoiceNumber = invoiceNumber.TrimStart("0"c)
Then last step will be:
-Search for Invoice Number : Iterate through the DataTable rows to find the matching row(s) based on the input invoice number. Use a For Each Row activity to loop through the DataTable and compare the “invoice_number” column with the modified invoice number (without leading zeros). If a match is found, store the row index or perform any desired action. Replace your variable with the variable to store the row index, and customize the action to be taken when a matching row is found.