How to process group of records in data table once instead of individually?

I’m getting stuck with the following scenario. I’m using a For Each Row in Datatable activity to read each line and subsequently filter for all invoices which have the same Customer Number and Email Address. An example data table I get is as follows:

image

The aim is to only send one email once to this email address which contains a data table containing the 2 records. My current workflow is sending an email twice capturing the same information. Would appreciate any advice!

So you have to remove duplicate value right.

Hi @copy_writes , if I remove duplicates, wouldn’t that mean I won’t be able to add the 2nd line (where Invoice Number = 289918) in my email? The aim is to advise the customer that they have these 2 invoices outstanding

Hi,

Hope the following sample helps you.

Sample20210601-2.zip (3.0 KB)

Regards,

2 Likes

Hi @Yoichi ! The code you provided would work. I’m keen to use it and I’ve tried incorporating it into my existing workflow but am getting stuck at the ‘Send Outlook Mail Message’ bit. How do I get Uipath to only email the grouped entries once? When I run my existing flow, it still emails the same customer twice since there are 2 invoice entries in the data table. Currently this is how my code looks like:

I do apologise for my lack of vb.net understanding…!

have a look here:

Hi,

Perhaps you should put SendOutlookMailMessage outside ForEachRow as the following.
item.Key.item2 returns mail address.

Regards,

1 Like

Thanks @Yoichi ! I realised I should have done that shortly after. It worked!
I have one last question, I’m using Create HTML Content to send the email to the customer in html format. Do you know how I can get the fields such as Invoice Number and Invoice Amount to appear in the body? I used the datatable ‘dt’ but it displays the entire data table instead of just the invoices specific to that customer and email address.

Actually, I used item.Value as the data table and it worked! Is there a way to only display certain columns from the data table in the email body instead of the entire data table?

Hi,

We can filter columns using FilterDataTable Activity as the following. Can you try this?

img20210601-6

Regards,

1 Like

@Yoichi , you have truly been a life saver. Thank you so much for all your help and expertise!

2 Likes

If you could post more details on that as a FAQ / do a video on that… I’ve read that multiple times and am not sure I really get it. But I know that the more you can do things like that in a few minutes, it greatly advances your developer skills. How did you learn that / do you have tips for understanding that?

1 Like

Hi @Bobby_J

Actually, I didn’t understand it at first. In my case, I deepened my understanding by reading basic LINQ expressions and actually writing and running repeatedly.
Now @ppr is working on making documents for LINQ (as the following, for example), and it will help us better understanding LINQ, I think.

Regards,

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.