How To: Dynamic email addresses

A question we get asked frequently is how to send an email from a form or flow submission where the email address of the recipient is dynamically determined at runtime. For example, I have a drop down control and if the user selects HR, I want the email to go to the HR Department (hr@example.org) and if the user selects Finance, I want to send it to Finance (finance@example.org).

It’s very easy in frevvo.

1. Create a hidden Email control in your form.

AdminEmail

Drag & drop an Email control in your form. In the Properties panel, uncheck Visible so the control is hidden from the end user. Name the control Admin Email. We assume that you already have a drop down control (in the screenshot, it’s called Department and the choices are HR and Finance).

When the user selects HR from the Department drop down, we’ll set the Admin Email hidden control’s value using a business rule.

2. Set the Admin Email address using a business rule

Create a simple business rule.

if (Department.value == ‘HR’) {
AdminEmail.value = “hr@example.org”;
} else if (Department.value == ‘Finance’) {
AdminEmail.value = “finance@example.org”;
} else {
AdminEmail.value = null;
}

In frevvo’s Winter release (expected in late 2017), you’ll be able to create these type of rules visually with the Visual Rule Builder.

3. Use the Admin Email control in the To: email

AdminEmailWizard

Email Wizard that uses a control template

In any Email wizard, you can use the Admin Email hidden control for the To:, Reply to:, Cc: and other fields. In the above example, we’ve used it for the To: field.

That’s it. When the User selects HR, the rule will set the Admin Email control to hr@example.org. When the form is submitted, the Admin Email template in the To: field will be evaluated and will resolve to the value of the corresponding control (hr@example.org). The email will be sent to the dynamically resolved email address.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: