# Manage Large Data Sets for Notification Routing

**URL:** https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730
**Category:** Get Help
**Tags:** custom, gform\_notification, routing
**Created:** [January 23, 2020, 4:46am UTC](https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730 "2020-01-23T04:46:05Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![wessa27](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/wessa27/32/1313_2.png) [@wessa27](https://community.gravityforms.com/u/wessa27)
#### Post date: [January 23, 2020, 4:46am UTC](https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730/1 "2020-01-23T04:46:05Z")

</div>

Hi All,

I have a form that will go to 30 different email addresses based on the result of the postcode field.

There are literally hundreds of postcodes. Manually entering them will be arduous. Managing them will be even worse as the form will be replicated many many times over.

Is there a way that the routing of postcodes could be managed in one central file (JSON?) or using the API? A 3rd party plugin?

I’ll keep digging. Thought I’d reach out & see if anyone has any suggestions.

Thanks Wes

---

<div class="post-metadata">

### Author: ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)
#### Post date: [January 23, 2020, 4:32pm UTC](https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730/2 "2020-01-23T16:32:48Z")

</div>

You can do that using the gform\_notification filter:

> **[gform\_notification - Gravity Forms Documentation](https://docs.gravityforms.com/gform_notification/#8-configure-routing)**
>
> Modify a notification object before it is converted into an email and sent.

Example #8 covers configuring routing. You would incorporate that approach with getting your date from a database or file of some sort, to create your rules from one source, dynamically as the source changes.

---

<div class="post-metadata">

### Author: ![wessa27](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/wessa27/32/1313_2.png) [@wessa27](https://community.gravityforms.com/u/wessa27)
#### Post date: [June 3, 2020, 7:29am UTC](https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730/3 "2020-06-03T07:29:36Z")

</div>

Thanks Chris, It’s taken me a while to circle back here.

I am wondering if the notification routing will accept ranges, as I have 16,700 postcodes and that’s a lot of data entry! 🙂

For example we want to send an email to [test@testcompany.com](mailto:test@testcompany.com) when the postcode fields is in the range of 2000-2012 & an email to [test2@testcompany.com](mailto:test2@testcompany.com) when the postcode is in the range of 3047-3059.

Any ideas? Appreciate the help!

---

<div class="post-metadata">

### Author: ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)
#### Post date: [June 4, 2020, 2:41am UTC](https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730/4 "2020-06-04T02:41:17Z")

</div>

No, the routing rules in the form builder for Notifications, or in the code, do not support a range. These are the comparisons which are supported:

- is
- is not
- greater than
- less than
- contains
- starts with
- ends with

There is no option to say `less than` AND `greater than`.

You may need a different approach. Instead of routing, can you use gform\_notification to just set the TO email address when the postcode is within your range. It would look more like example 2 here [https://docs.gravityforms.com/gform\_notification/#2-change-to-or-totype-settings-for-user-notification](https://docs.gravityforms.com/gform_notification/#2-change-to-or-totype-settings-for-user-notification) with lots of switch/case statements or if/then statements.

Or, maybe you could store the postcode and the associated email address in a database table or file, and perform a lookup in the gform\_notification filter. That way, you would not have a lot of code, and would have a database table with the postcodes and the email addresses, and you would query the database in your code to find the email address that matches your postcode.

---

<div class="post-metadata">

### Author: ![wessa27](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/wessa27/32/1313_2.png) [@wessa27](https://community.gravityforms.com/u/wessa27)
#### Post date: [June 9, 2020, 2:51am UTC](https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730/5 "2020-06-09T02:51:48Z")

</div>

Thanks Chris!

This worked out pretty well. Thank you.

I didn’t go down the track of a JSON file, I just put all the rules into the functions.php file and consolidated the postcodes where possible. I think in the future I will get something happening with a JSOn file for easier management, I just didn’t have time for it.

Along with the email notifications being routed, there is a separate notification that is a ‘catch all’ email that goes to the main client (head office). They have now requested that I push a field through to their separate notification that has an additional field that shows which email the first notification was routed too.

Any clues what I might be able to do with this?

Really appreciate your input!

Cheers, Wes

---

<div class="post-metadata">

### Author: ![wessa27](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/wessa27/32/1313_2.png) [@wessa27](https://community.gravityforms.com/u/wessa27)
#### Post date: [June 9, 2020, 3:31am UTC](https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730/6 "2020-06-09T03:31:55Z")

</div>

perhaps this [https://docs.gravityforms.com/gform\_routing\_field\_types/](https://docs.gravityforms.com/gform_routing_field_types/) ?

---

<div class="post-metadata">

### Author: ![wessa27](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/wessa27/32/1313_2.png) [@wessa27](https://community.gravityforms.com/u/wessa27)
#### Post date: [June 9, 2020, 3:37am UTC](https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730/7 "2020-06-09T03:37:40Z")

</div>

For the record, I used this for the routing:

add\_filter( ‘gform\_notification’, ‘notification\_routing’, 33, 3 );  
function notification\_routing( $notification, $form, $entry ) {  
if ( $notification[‘name’] == ‘Admin Notification’ ) {  
$notification[‘toType’] = ‘routing’;  
$notification[‘routing’] = array(

```
    array('fieldId' => 12,'operator' => 'contains','value' => '200','email' => 'act@act.spanline.com.au'),
	array('fieldId' => 12,'operator' => 'contains','value' => '221','email' => 'act@act.spanline.com.au'),
	array('fieldId' => 12,'operator' => 'contains','value' => '2581','email' => 'act@act.spanline.com.au'),
	array('fieldId' => 12,'operator' => 'contains','value' => '2582','email' => 'act@act.spanline.com.au'),

```

etc. etc.

---

<div class="post-metadata">

### Author: ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)
#### Post date: [January 4, 2022, 6:04pm UTC](https://community.gravityforms.com/t/manage-large-data-sets-for-notification-routing/3730/8 "2022-01-04T18:04:08Z")

</div>


