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.