Buy Now
Sign in

Email function in a loop

Roaf , March 08 at 22:31
I have a CC6 form set up where an admin has to confirm an order, by checking a selector checkbox, then hitting a confirm task button.
In that form are emails for customers, in which I was hoping that when an admin confirms the order, it would automatically send an email to the customer (whose data is stored in the view table).
I can get it to work by adding two things into the 'Confirm Selected' event (event runs when the Confirm task button is pressed). 1. I added a read data function called read_order, and an email function called 'Confirm_Email'.
I added var:read_order.model_order.person_email to the recipients field and it will send an email because it first reads the data via read_order and then sends the email.
The problem arises because the read_order is set to "First Matching Record" is the only I could get it to work, if I try to make a loop event, im unsure what exactly to put as the data provider, and how to make it send multiple emails,- like if an admin selects 3 rows and then hits 'Confirm Selected', I wanted it to send 3 separate emails to 3 separate customers who were checked.
Ive tried setting the read_order function to "All Matching Records" but then I debug and see the array return 3 data sets, but I cant seem to get the syntax for the recipient correct.
Attached is a debug picture of the read_order function running, what would the recipient syntax be to properly grab the green and blue items (I censored out the actual emails).cc_email.JPG
Hi Roaf,
Set the data provider of the Loop to {read_order} then call the email function inside the loop and use {var:loop_name.row.model_order.person_email} in the "Recipients" setting.
Best regards
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!