`beforeSubmit` isn't aware of Copy events; it sees...
# suitescript
e
beforeSubmit
isn't aware of Copy events; it sees a copied record the same as a Create. Is there some other customization running later on
beforeSubmit
, on
afterSubmit
, or on
beforeLoad
that would be modifying the value of this field in question as well?
t
Nothing is running after this script that would modify any of these fields
Copy code
define(['N/record', 'N/format'],
    function(NS_record, format) {

        function beforeSubmit(context) {
            var stMethodName = 'beforeSubmit';
            try {

			var recCurrent = context.newRecord;
			
			var useCustShip = recCurrent.getValue('custbody_use_cust_ship');

			if(((context.type == context.UserEventType.EDIT) || (context.type == context.UserEventType.CREATE)) && useCustShip != true){

				recCurrent.setValue('custbody_customer_ship_billing_zip', ''),
				recCurrent.setValue('custbody_customer_ship_acct', ''),
				recCurrent.setValue('custbody_customer_ship_billing_country', ''),
				recCurrent.setValue('custbody_customer_ship_carrier', '')
								
				}
				
				} catch (error) {
                log.error(stMethodName, error.message);
            } finally {
                log.debug(stMethodName, '* * *  E n d  * * * ');
            }
        }

        return {            
            beforeSubmit: beforeSubmit
        };
    });
s
Well you've told it to only fire on EDIT and CREATE, have you double checked COPY isn't actually what the context is? I would assume Eric is correct but doesn't hurt to make sure.
t
Eric is correct. The code above is the updated code after Eric mentioned that copy isn't a recognized event. I did mean to post my original code, which had
context.type == context.UserEventType.COPY
in the if statement.
Thanks guys! Really appreciate the help!