/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */
define(['N/record'], function(record) {
    function beforeSubmit(context) {
        if (context.type === context.UserEventType.COPY) {
            var soRec = context.newRecord;
            var customerId = soRec.getValue({ fieldId: 'entity' });
            if (customerId) {
                var customerRec = record.load({
                    type: record.Type.CUSTOMER,
                    id: customerId
                });
                var terms = customerRec.getValue({ fieldId: 'terms' });
                if (terms) {
                    soRec.setValue({
                        fieldId: 'terms',
                        value: terms
                    });
                }
            }
        }
    }
    return {
        beforeSubmit: beforeSubmit
    };
});