Use data from 1 record from a database to use for actions

n.assmann 22 Jan, 2013
I have a form with a text box with fieldname <form_teamID>
When a user puts in his ID, and press the submit button, I want to get from a database one record where the keyfield <teamID> is equal to the given <form_teamID>. In that record there is a field <emailadres>. I want to use that emailadres to sent a e-mail to this adres, and I want to sent a e-mail to myself with this e-mailadres in the from e-mail field.

What events do I use, and how?
GreyHead 23 Jan, 2013
Hi n.assmann,

You can use a DB Record Loader action in the On Submit event to look up a record from the id entered in the form. Then use the results of that in the Dynamic To Email box of one Email action and the Dynamic Reply To Email box of a second action.

Bob

I strongly recommend that you do *not* use the Dynamic From Email element in your Email Setups. Using this often results in your emails being marked as spam and dropped into a spam filter. Instead use the static From Email with an address that matches the site domain name and use Dynamic ReplyTo Email for the user email. The result is the same but with a much better chance of good delivery.
n.assmann 23 Jan, 2013
I added a DB Record Loader, where do I put the 3 neccesary fields?
- form_teamnummer (I think: Basic -> DB Field)
- teamnummer (I think in the where-statement: teamnummer = form_teamnummer ???)
- emailadres (this is the data I want to use, where do I ask this within the DB Record Loader)
GreyHead 25 Jan, 2013
Hi n.assmann,

I think you need:

DB Field = teamID
Request Param = form_teamID

Then the email you want should be in $form->data['emailadres'] so you can use emailadres in the Dynamic To box.

Bob
n.assmann 28 Jan, 2013
Then the email you want should be in $form->data['emailadres'] so you can use emailadres in the Dynamic To box.

I really do not understand what you are saying here above.

What do I exactly put in the "Dynamic to"-field of the e-mail-action.
And what do I need to fill in the DB Record Loader-action so that I can use the e-mailadres from the DB ?
GreyHead 28 Jan, 2013
Hi n.assmann,

What do I exactly put in the "Dynamic to"-field of the e-mail-action.


emailadres

And what do I need to fill in the DB Record Loader-action so that I can use the e-mailadres from the DB ?


DB Field = teamID
Request Param = form_teamID

and the correct Table selected in the drop-down

Bob
n.assmann 28 Jan, 2013
email action 1 : send a e-mail to my own e-mailadres:

this works. but if I click reply, than the reply mail will be send to "static from email" AND "dynamic reply to email". I only want to sent the reply to the second, and not the first. But I cannot leave the "static from email" empty because its required within the action, and because you adviced not to fill in the "dynamic from email", I have to fill it in. How to do this?

email action 2 : send a e-mail to the emailadres in the DB:

this doesn't work, but I did fill in the "dynamic to" with emailadres ?
GreyHead 28 Jan, 2013
Hi n.assmann,

For 1: Please see this FAQ

For 2: Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.

Note: if you are using the Easy Wizard you can turn on Debug on the Others tab.

Bob
n.assmann 29 Jan, 2013
I got it working. I forgot one little detail. Thanx for your help.

***

Now I only need to change the record I have selected in the "DB Record loader".
I think I have to place a "DB Save action" within the "On record found" part.

The record has a field called "ingeschreven" with 3 values: 1, 2 and 3
It has to change from '1' to '2'.

How do I fill in the action to do this?
And will it then automatically be affected on the record selected by the "DB Record loader" ?
GreyHead 30 Jan, 2013
Hi n.assmann,

You need to make sure that the ID of the record you want to update is in the form data. Usually the easiest way to do this is to add a hidden input with the same name e.g. cf_id

Bob
This topic is locked and no more replies can be posted.