Two Queries to Send Email

Can I have more than one db query in 1 action step that will do separate things? Here’s what I have:

!. Query the accounting assistant’s info to whom the email report will be sent
2. Query the data to populate the report to be emailed.

I need the email to be sent after the submit button is clicked to insert that data to the database.

The order of my action steps:

  1. Database Connection
  2. Query accounting assistant’s data
  3. Setup Mailer
  4. Query report data
    a. Repeat this query
    b. Send Mail

See image below:

My Problem : When I start inserting the data bindings into the email, the report data bindings under the repeat step are seen, however the previous query in the steps for the accounting assistance the database name is seen, but the individual data binding results of that table are not seen.

What am I doing wrong?

Thank you for any help.

  • Is the output checkbox for that query on?
  • Is there more than one record returned from the gm_accounting step?
  • If there is more than one row returned on the gm_accounting step, then you need a repeat after that step, and then your career_inbound_orientation_finance query inside the repeat.
  1. Database Connection
  2. Setup Mailer
  3. Query accounting assistant’s data (Output Off)
  4. repeat (Expression: Query accounting assistant’s data) (Output On)
  5. inside repeat steps - Query report data (Output Off)
  6. repeat (Expression: Query report data) (Output On)
  7. inside repeat 2 steps - Send Mail
1 Like

all you have to do is type the expression you will not find it in the formater
{{queryname[0].column}}

if your query have more than one record then do a repeat with the expression to get the columns to show on the formater.

1 Like

Sorry for the delay…

There is only one record returned for each.

What exactly does the output checkbox initiate?

Also, to send the email after the submit (insert) is clicked, do I just add these steps to the existing insert?

No problem, all the output checkbox does is either show the query parameters as accessable in the other steps or hide them, it is really just to avoid confusion when you are binding things and there are two choices with the same name.

Basically the query step needs to execute in order to get its values so you can use them in secondary steps which is why i suggest adding the repeat step, as the repeat executes the query. However if you are only ever getting a single result then you can access it directly as per what @mrbdrm said.

I would still use the repeats.

I am not really sure what you mean here, can you explain more please

Have you tried the steps as i outlined them as yet to see if it is working.

Any chance of a few screenshots please. 1 of all the steps inside server connect as you sent in post 1 but with my proposed layout. 2 a pic of query 1 params. 3 a pic of query 2 params. Also if there are conditions pics of those too.

Put the code in condition action and see if the query return any results

I will be back later this evening and will give this a try on my side, or take a look through some of my files where I know i have done something similar.

I tried this out but seems I am having the same issue as you getting to the data from the first query. I think we are both going to have to ask @Teodor / @George or @patrick to help try figure this out

1 Like

Have you guys tried this?

1 Like

I did, and yes it works, I have to use this sort of method quite often, however I have an issue using that when i need more than a single record, I know it works if you only need one.
also tried {{queryname[$index].column}} to see if there was a way to get more records.

1 Like

Thank you very much… I will give it a try asap.