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

2 get items to send email with multiple data

I`m looking to send a customized email with data pulled out from a SharePoint lists.

The main SharePoint list is used for the trigger when a new item is created"

Then i need to lookup names and email addresses from 2 other SharePoint lists using a unique identifier between each one of these lists  ( Child1 & Child2)and the main sharepoint list.

then to take all these data to the action " Send email V2" to send a customized email.

 

However, i managed to do so but with only one child list "one child list instead of 2"

 

PS: in the final " apply to each" : if i used values from the "Child2" or inserted any data pulled out from child2 in the email body, it get never sent.

 

Can you help me with this 

1 ACCEPTED SOLUTION

Accepted Solutions

If you initialize the variables outside the loops and then set them inside the loops, then the values will be available when you send the emails after the loops have completed.  This should give you access to both sets of results.



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

View solution in original post

10 REPLIES 10
Pstork1
Dual Super User
Dual Super User

Since you are using two Get items I assume you are using two Loops to get the values out of the items.   If that's true then the values you read in one loop will not be available in the second loop directly.  You need to create variables and save the values in one of the loops into some other form, like a comma delimited string or array. Then you can use those variables in the second loop to populate your email.



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

here is the flow.

 

it works only when i select "Value" from first "Get item".

 

I`m not a heavy Flow user, so would you kindly explain a bit more to me how it can be done ?

 

Thanks.
Regards

part1.JPGpart2.JPG

What values are you trying to get from each item and put in the email?  How do you want to format them.  The point is that you can only process one Get Items action in a loop at a time.  So you have to process one set of records and then the other.  So you have to either store the values you want to use in a second loop or put one loop inside the other.



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

look the major list contains unique identifiers that can be matched with the 2 child lists and the total sold products 

child 1 : contain the name of the product " : using the 1st uniqie identifier code
child 2 : Contain the Name of the Customer

in the email i need to combine data from the 3 lists ( the main list and both the child lists )

Dear CustomerName,

We would like to thank you for purchasing ProductName from our store.
Please note that you have paid : Total_Price 

Customer Name & Email adress of the customer : found in list 1
Product name & price : found in list 2

Number of units and Total Paid : found ready in the main list.

 

How would you advice?
Thanks in Advance.

Use 2 Get Items with Odata queries that limit the returned records from each list to the one you want.  Process each of those returns using a First() function to get the First record returned and store it in an object variable.  You now have two object variables that contain the values you want from each list.  Use properties of those objects in your email.



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

I have done as below in the attachments 
Would you please tell me if i`m right or not ?

In the send email part it always ask for value from Get1 or Get2 .. what would you suggest

 

Thanks.

part1 new.JPG

1) Not sure how you got the intitialize variable actions inside the loop.  Normally that will generate an error.  You have to initialize them outside the loop and set them inside the loop, assuming you are using a loop since I suggested you use First() instead.

2) I don't understand what you mean when you say the send email asks for Get 1 and Get 2.  You've stored those values in the string variables so that you can use them in the body of the email.



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

Thank you for your patiance, 

 

What i mean is that when i`m building the email template i can use only items from on of the lists but not both at the same time.

What i want to do is to get A,B,C,X from list 1  & Get D,E,F from list 2

and in the email action
---------------------------
Send to : A
Subject : E
CC : C

Dear X,
please note that D has been submitted with the price F.

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

would appreciate your advice,

thanks.

If you initialize the variables outside the loops and then set them inside the loops, then the values will be available when you send the emails after the loops have completed.  This should give you access to both sets of results.



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

here is what i got.

 

the flow runs any way but the faded item here is not appearing in the email.

 

Faded.JPG

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (5,049)