Send transaction to multiple email addresses

Introduction

When you create a new transaction (i.e. Sales Order, Invoice), NetSuite will automatically source the “To Be E-mailed” field using the email field from the customer record (See below).  This is okay if you just want to send to one email address, but what if you want to send to multiple email addresses?  NetSuite does not have a native way to accomplish this.  This article will detail how to do this using either a custom record or the contact record and SuiteScript.

 

Option 1 : Custom Record – “Customer Email Address”

This custom record will have two fields.

  1. Customer – List/Record Customer – Select Record is Parent and put on “Communication” tab
  2. Email – Email Address

 

On the Customer record you will now see a new tab on the communication tab.  This is where you will add and remove email addresses.

 

 

Option 2: Contact Record

Add a custom checkbox entity field to the contact record. You would check this box to have the email address show up in the “To Be Emailed” text field.

 

Custom Entity Field

 

SuiteScript

There is one client script that you can deploy on any transaction record which has a customer and can be emailed (i.e. Sales Order, Invoice).

Client Script Summary:

  • On the creation of a transaction or if the customer is changed:
  • Script will search for all email addresses using:
  • Option 1: Custom Record.  It will get the email in the “Email” field on the customer record.
  • Option 2: Contact record. It will get the email for all contact where “Send Transaction” is checked.
  • The “To Be E-mailed” checkbox will be checked.
  • The email field will be set to all the email addresses from customer record.

The code:

/**
 *@NApiVersion 2.1
 *@NScriptType ClientScript
 */

define(['N/search'], (search) => {

        pageInit = (context) => {
            if (context.mode === 'create') {
                const newRecord = context.currentRecord;
                loadEmails(newRecord);
            }
        }

        fieldChanged = (context) => {
            const field = context.fieldId;
            const currentRecord = context.currentRecord;
            if (field == 'entity') {
                loadEmails(currentRecord);
            }
            return true;
        }

        loadEmails = (newRecord) => {
            const customer = newRecord.getValue('entity');
            if (customer) {
                let emails = [];
                /********************************/
                /* Option 1 - use custom record */
                /********************************/
                /*
                const customerEmailSearch = search.create({
                    type: "customrecord_customer_email_address",
                    filters: [
                        ["custrecord_customer_email_customer", "anyof", customer]
                    ],
                    columns: [
                        "custrecord_customer_email_email"
                    ]
                });
                customerEmailSearch.run().each(function (result) {
                    emails.push(result.getValue('custrecord_customer_email_email'));
                    return true;
                });
                */
                /************************************************/
                /* Option 2 - use Contacts from customer record */
                /************************************************/
                const customerEmailSearch = search.create({
                    type: "contact",
                    filters: [
                        ["company", "anyof", customer],
                        "AND",
                        ["custentity_send_transaction", "is", 'T'],
                    ],
                    columns: [
                        "email"
                    ]
                });
                customerEmailSearch.run().each(function (result) {
                    emails.push(result.getValue('email'));
                    return true;
                });

                const fieldLookUp = search.lookupFields({
                    type: search.Type.CUSTOMER,
                    id: customer,
                    columns: ['email']
                });
                emails.push(fieldLookUp.email);
                let allEmails = emails.join(';');

                newRecord.setValue('tobeemailed',true);
                newRecord.setValue('email', allEmails);
            }
        }

        return {
            pageInit: pageInit,
            fieldChanged: fieldChanged
        };
    });

Conclusion

I hope you enjoyed reading about this simple customization.  If you need help with customizing NetSuite, please contact Suite Tooth Consulting and we would be happy to help you.

Follow on
Jaime Requena Chief Executive Officer

Jaime Requena is a seasoned NetSuite Consultant and Solutions Architect, known for delivering WHITE GLOVE service to businesses. With 15+ years of experience and 3x certifications in ERP, Developer, and Admin, Jaime specializes in highly customized NetSuite accounts, transforming operations for 200+ satisfied customers all across the globe.

Get Connected

How can we help?


    Stay in the loop with Suite Tooth Consulting!

    We aim to bring unmatched expertise and professionalism to your NetSuite initiatives. Let’s talk about how our NetSuite consultancy can make a difference!

    Global Client Satisfaction

    Client Testimonials

    It’s Been 4+ Years Now And We Have Worked With Hundreds Of Clients, Building Our Way To The Top, One Happy Client After Another! Their Voices Of Satisfaction Serve As A Testament To Our Success –