Learn how to use SuiteScript to clear fields when copying a transaction

Introduction

A customer recently had an issue with transactions that were being copied. The problem here was certain fields were not being cleared by the user. This led to problems as the data on these transactions was incorrect. In this article I will show you how to use SuiteScript to clear fields when a sales order is copied.

Step 1: Decide which fields should be cleared when a transaction is copied.

For this example, we want the field “memo” cleared.

Step 2: Deploy the below user event script to the sales order.

This script will clear the “memo” field when the sales order is copied.  Reference my article “Quick Guide to Adding and Deploying a Script in NetSuite” if needed.

 

/**
*@NApiVersion 2.1
*@NScriptType UserEventScript
*/

define([],
    () => {
        beforeLoad = (context) => {
            if (context.type === context.UserEventType.COPY) {
                const newRecord = context.newRecord;
                newRecord.setValue('memo','');
            }
        }

        return {
            beforeLoad: beforeLoad
        };
    });

Step 3: Find a sales order and copy it.  You will see that the memo field has been cleared.

This sales order has data in the memo field:

 

 

Select “Actions” -> “Make Copy”.  See the memo field has been cleared:

 

Conclusion

This simple script can save you a lot of clean up time if you are copying a lot of transactions and need to clear fields.  If you need help with customizing NetSuite, please click here to set up a consultation.

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 –