Jadu Forms: Set Email Recipients by Environment Using Emails Chosen by Form Submitter

It's useful to make sure that emails generated by a form go to an appropriate test account during the testing phase of building a form, but go to the correct recipient(s) once the form is in production.

This method is best suited for when you want to allow form testers to enter their own email addresses. With this method, the production email addresses are hard-coded, but when the form is being used in the Test environment, it will dynamically request the user to enter a testing email.

For a simpler alternative method that uses form builder-defined email addresses for testing, see the page Set Email Recipients Based on Form Environment Using Emails Defined by Form Builder.

In this article:

 Creating a Logic to Determine Current Environment (Test or Production)

  1. Under the Logic tab, add a new Logic to the form.
  2. Choose the Type Predefined.
  3. Select UMN - Jadu - Current Environment from the Formula drop down list.
    Jadu New Logic window with Predefined type selected and UMN - Jadu - Current Environment chosen in Formula dropdown
  4. Give the logic a user-friendly name and select the Save button.

Creating a Prefilled Hidden Field

Next you will create a Hidden Field on your page and prefill it with the output from the current environment logic created above. This will be used to conditionally show or hide an email address field to the form submitter based on the current environment.

  1. In the page editor, add a Hidden Field component to the page.
  2. In the Hidden Field pop up window, give the component a user-friendly name.
    Jadu New Component pop up window with Current Jadu Environment (hidden) title, Hidden Field Component type, and blank Value field
  3. Select the Add Component button (leave the Value field empty).
  4. Exit the page editor by selecting the Return to Form Structure button.
  5. Under the Prefills tab, add a new prefill for the hidden field.
  6. In the Prefill pop up window, select the following options from the drop down lists:
    1. I want to prefill - select the Hidden Field you created above
    2. With the value of - select the Predefined Logic you created above
      Highlight box showing a completed Prefill
  7. Select the Save button.

Creating a Conditional Section Based on Form Environment

Now you will create a section on your page that only shows up when the form is being filled in the Test environment. The section will have a question where the form user can enter the email address(es) that they want the test email to go to.

  1. Return to the page editor and add a new Section element to the page.
  2. Give the section element a user-friendly title
  3. In the New Section configuration pane, select the following options:
    1. Show section - click the Conditionally button
    2. Show when - select Comparison of (a new selection box will appear below)
    3. Choose your Hidden Field (a new selection box will appear below)
    4. Select is not equal to (a new text entry box will appear below)
    5. Type PRD in the final field
      Highlight box showing the completed New Section configuration Pane
  4. Click the Add Section button.
  5. Add a new Text Field element to the section you just created. Be sure to drag the element inside the Section.
  6. Enter user-friendly question text requesting the testing email address(es) in the Text Field.
    1. Consider adding Help text with formatting for multiple emails (comma-separated with no spaces). 
    2. Then click the Add Question button.
  7. Exit the page editor by clicking the Return to Form Structure button.

Creating a Logic to Switch Emails Based on Environment

Finally, you will add a Conditional Logic that will automatically switch the email recipients depending on the environment. It will use hard-coded email addresses for the Production environment, but will take the user-supplied email addresses when in the Test environment.

  1. Under the Logic tab, add a new Logic to the form.
  2. Give the logic a user-friendly title.
  3. Choose the Type Conditional and then build out the conditional formula as below.
    1. If environment is Production, Then Return {Production Email}; Else Return {Response to Email Question}
      1. In the If statement box, select the Predefined Logic you created above in the first field. Select is equal to in the second field. Finally, type PRD in the last field.
      2. In the Return box, enter the production email address(es). This is where the email will be sent when the form is in the Production environment.
      3. In the Else Return box, enter the Text Field question you created above. This is where the user will enter their testing email addresses to send to.
        Highlight box showing a completed Conditional Logic
  4. Click the Save button.

Adding Logic to Email Template

To use the Logic created above to switch the recipients of an email template based on the environment, follow the steps below

  1. Open your existing action email template or create a new one.
  2. Click the # Variable button next to the To field in the email template.
    Jadu New Action Template window with Email to Approver title, and # Variable button next to the To field highlighted
  3. In the Insert Variable pop up window, click on the Logic tab and then click Insert next to the Conditional Logic that you created above.Jadu Insert Variable pop up window on Logic tab displaying the Logic name Switch Recipient Email Based on Environment with Insert option highlighted
  4. You should now see your Conditional Logic inserted as a variable in the To field of the email template.Jadu New Action Template window the To field populated with Logic Switch Recipient Email Based on Environment

Your email template is now ready to be used in a rule. Now every time the email template is triggered by a rule, Jadu will first check to see what environment the form is in and then send the email to the correct recipient(s).

Last modified

Changed

TDX ID

TDX ID
7829