/** * @NApiVersion 2.0 * @NScriptType UserEventScript * @NModuleScope SameAccount */ define(['N/error', 'N/record', 'N/runtime', 'N/search', 'N/log'], function(error, record, runtime, search, log) { function beforeSubmit(scriptContext) { /** log.debug('DEBUG', 'Starting function'); var customerRecord = context.newRecord; var compname = customerRecord.getValue('companyname'); if(compname.indexOf(' ') == 0) { var errorObj = error.create({ name: 'LEADING_SPACE', message: 'The CUSTOMER name cannot begin with a space', notifyOff: false }); throw errorObj; log.debug('DEBUG', 'Threw leading space error'); } **/ } return { beforeSubmit: beforeSubmit }; });