cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jimxmy
Frequent Visitor

How to send an email to the owner of the leads created in the last week?

Hi.


So I want to send an email to the owner of the leads on every Tuesday showing him/her the number of leads created as well as the lead topics/name in the last week. 

Is there any way to achieve this? I was thinking of creating scheduled flow in the power automate but I am not sure how to capture the number of leads created by the owner or anything of that sort. 

Any help/suggestions to this is appreciated.

Thank you. 

9 REPLIES 9
Gericom
Resolver II
Resolver II

Hi @jimxmy 

 

it depends on where you will save the leads.

if you will save them in excel you can use 

https://powerusers.microsoft.com/t5/Building-Flows/Send-an-unique-email-from-Excel-file/m-p/936148#M...

 

the concepts stay the same for sp list or excel 

if you have any questions I'm glad to help you 

with kind regards

--------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up

 

jimxmy
Frequent Visitor

Hi.

Regarding leads, I want to fetch it from the Dynamics 365 environment. So maybe a CDS connector or a Dataverse one would be good to go?

Also, not sure how to filter through the last 7 days of the listed records that I'd be able to fetch from the connector. 

Thanks. 

Gericom
Resolver II
Resolver II

hi you can use created on addDays(utcNow(),-7)

 

if you have any questions I'm glad to help you 

with kind regards

--------------------------------------------------------------------------

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up

jimxmy
Frequent Visitor

@Gericom @ChrisPiasecki 

Hi.

I have created a scheduled flow for the same but somehow it is in the infinite loop while in 'send an email' action.

Here is my flow:

 email1.PNG

 

 

email2.PNG

Hi @jimxmy,

 

You should use the Dataverse connector and List Rows action. You can specify a filter query of:

createdon ge addDays(utcNow(),-7)

 

---
Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

 

@ChrisPiasecki 
Hi, I tried with dataverse as well but the flow is getting stuck on the last step of sending the email as I have shown in the flow. Something is missing here and I am lost. 

 

If by an example, you could show how it could be done, would be greatly appreciated.

Thanks anyways. 

Hi @jimxmy,

 

Perhaps there is a connection issue with the Email connector you are using? Can you try a different flow with just that Send Email Notification action and confirm if it works on its own?

 

---
Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up. 

@ChrisPiasecki 

The connector works fine, I am guessing the conditions are wrong. How to actually split the details of leads by topic and owner and then group them by their owner so that I can create an HTML table for the same for every owner group?

Also, the sending email part would be tricky because I'd be needing to put in the internal email address from the users entity. 
I have been able to get single leads details but I want them in group for the situation if someone has more than one leads created in the last seven days.
Any take on to this complex issue? 

Thanks.

Hi @jimxmy,

 

You can try the following:

 

1. Get all leads from last 7 days. You can use an expand query to get the owning user's email address.

ChrisPiasecki_0-1623622567135.png

 

2. Use a Select action to create a new array that has just your owning user id and email address. Then add a Compose action to get your distinct list of users with leads using the union expression.

ChrisPiasecki_1-1623622858314.png

 

3. Save and test your flow, then copy the output from the Compose action, then edit the flow and add a Parse JSON action to generate a schema so you can reference the fields in your array in following steps.

4. Add an apply to each step to loop over your distinct set of users.

5. Add a filter array action to filter your list of retrieved leads based on the current distinct user in your loop.

ChrisPiasecki_2-1623623051434.png

 

6. Save and test your flow. Inspect the filter array output and take note of the column names you want to include in your HTML table next as you will reference them via expressions.

7. Edit your flow and add a Create HTML Table step. Use custom so you can just pick which columns you want from your filtered list of leads. Use the expression to reference your columns you took note of in previous step (e.g. item()['fullname'])

ChrisPiasecki_4-1623623361729.png

 

8. Finally you can add a send email step where you can add in your HTML table into the body, and you should have the recipients email from the apply to each item.

 

Hope this helps.

---
Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (915)