Jaime Requena
–
January 10, 2023
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.
For this example, we want the field “memo” cleared.
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
};
});
This sales order has data in the memo field:

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

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.
Do not hesitate to contact us. We’re a team of experts ready to talk to you.