Routing Notification for Multiple Select Choices [RESOLVED]

I am migrating form from Caldera to Gravity and we are stuck with the Routing notification for 2 selected values. Basically we have a form select field for Practice Area and a select field for County.
So email-1 should receive notifications when:
Practice Area → Business Law AND is County → Sussex,
So email-2 should receive notifications when:
Practice Area → Business Law AND is County → New Castle,
So email-3 should receive notifications when:
Practice Area → Nursing Law AND is County → Sussex,

Unfortunately, this is not possible with the current routing rules as the only available conditions were (is, is not, greater than, less than, contains, starts with, ends with)

This type of routing requires custom coding to create conditional notifications based on specific values of multiple fields. You can use Gravity Form’s hook system or a plugin to accomplish this. Here’s an example using the gform_notification hook:

add_filter( 'gform_notification', 'change_notification_email', 10, 3 );

function change_notification_email( $notification, $form, $entry ) {
  $practice_area = rgar( $entry, '2' );
  $county = rgar( $entry, '3' );
  if ($practice_area == "Business Law" && $county == "Sussex") {
    $notification['to'] = "email-1@example.com";
  } elseif ($practice_area == "Business Law" && $county == "New Castle") {
    $notification['to'] = "email-2@example.com";
  } elseif ($practice_area == "Nursing Law" && $county == "Sussex") {
    $notification['to'] = "email-3@example.com";
  }
  return $notification;
}

In this example, the hook checks the values of the Practice Area and County fields and routes the notification to the appropriate email address based on the specified conditions. The field IDs (2 and 3 in this case) must be updated to match your form fields.

Thank you Faisal for this very detailed explanation. This is a good way to achieving what I need but my client isn’t familiar working on codes as we do and they can’t keep track on these emails directly on the Notification settings. I can say this functionality should be included in the future updates of Gravity whereon in Caldera and Ninja this is readily available.

Again, I really appreciate your help.

1 Like

You’re welcome! I’m delighted that I could be of assistance. I understand that your client may find it difficult to keep track of the emails through the notification settings.

I appreciate your kind words and thank you for your feedback. Please don’t hesitate to reach out if there’s anything else I can do to help.