Collection output

(Peter) #1

I am trying to output a result of a query to an email. There are three collections which are being sent like this in a body:

Your course {{run_a_queryallcourses.result__rows__0__name *}} starts at {{run_a_queryallcourses.result__rows__0__StartDate *}} - see our website at {{run_a_queryallcourses.result__rows__0__permalink *}}

This is fine, but I’d like to add a greeting and a few words before the list of courses as well as a goodbye after. But if I add it like this

Dear user,
thank you for your question.

Your course {{run_a_queryallcourses.result__rows__0__name *}} starts at {{run_a_queryallcourses.result__rows__0__StartDate *}} - see our website at {{run_a_queryallcourses.result__rows__0__permalink *}}

Good luck

then I have the greeting and everything repeated too.

So how do I list those three collections and not repeat the rest? I thought about listing the collection with the &/&& notation, but it does not allow me to list the collections by one item: I get all names first, then all dates and then all links.

Any suggestions?

(Peter) #2

Well, I kind of sorted it out by running a code and sending its output as a body for message.

This may be an inefficient solution, but it works. Would still be great to know if there is a neat workaround.

(Daniel Beckett) #3

Can you try without adding a collection output? i.e. leave the box empty when it comes up and just hit enter to save it. Should make the output look like normal: {{run_a_queryallcourses.result__rows__0__name}}

(Peter) #4

I certainly can, but this will only output the first item, won’t it?

The reason for using the collection is simply because this is how SQL query outputs the result. Thus I basically have a collection of courses each having StartDate, Name, Link etc. So I want to send the user an email like

Dear ...,

We are glad you have chosen us. Below are your courses:
Name1 starting at StartDate1 - see details at Link1,
Name2 starting at StartDate2 - see details at Link2,
<etc>

Best of luck. Hope to see you soon.
Yours, ...

I am obviously able to send a list as in the middle by writing

{{query.result__rows__0__Name *}} starting at {{query.result__rows__0__StartDate *}} - see details at {{query.result__rows__0__Link *}}

But if I add the header and a footer in the message like

Dear ...,
We are glad you have chosen us. Below are your courses:

{{query.result__rows__0__Name *}} starting at {{query.result__rows__0__StartDate *}} - see details at {{query.result__rows__0__Link *}}

Best of luck. Hope to see you soon.
Yours, ...

I see a message like:

Dear …,
We are glad you have chosen us. Below are your courses:

Name1 starting at StartDate1 - see details at Link1

Best of luck. Hope to see you soon.
Yours, …
Dear …,
We are glad you have chosen us. Below are your courses:

Name1 starting at StartDate2 - see details at Link2

Best of luck. Hope to see you soon.
Yours, …
Dear …,
We are glad you have chosen us. Below are your courses:

Name1 starting at StartDate3 - see details at Link3

Best of luck. Hope to see you soon.
Yours, …

And so on. I.e. the header and the footer are repeated too.

So now I run a code adding two items to a collection (text header and text footer) and then using its output for the email. But that seems kind of a wrong solution for me.

(Karen Barker) #5

Hi @Peter,

Unfortunately when using the magic repeat function it will repeat everything in the send message action. It would be difficult to be able to work out a users intent as to what needs to be repeated and what doesn’t.

Another option to get around this would be to send the Header as one message, then the section with the collection outputs and then the footer as a 3rd message. :slight_smile:

1 Like
(Alexey Klepov) #6

Hi @KarenBarker and @DanielBeckett.
I’ve also meet with magic repeat, which repeating everything in the send message action. This is not comfortable to use. May be you have in plans to make a solution to divide which part of message will be repeated and which not.

(Karen Barker) #7

Hi @mr.Klepoff,

Unfortunately at the moment there is no plans to change how the magic repeat works. If you would like to add this to our feedback site then it will definitely be looked at as a future change by the development team. :+1: