Hanna Johns
07/24/2025, 5:09 PMAnthony OConnor
07/24/2025, 5:13 PMAnthony OConnor
07/24/2025, 5:16 PMform.clientScriptModulePath = 'customscript1666'; // Path to your client script file
Anthony OConnor
07/24/2025, 5:16 PMAnthony OConnor
07/24/2025, 5:18 PMform.clientScriptModulePath ='SuiteScripts/TSOL - Commercial User.js';
Anthony OConnor
07/24/2025, 5:19 PMHanna Johns
07/24/2025, 5:27 PMHanna Johns
07/24/2025, 5:28 PMHanna Johns
07/24/2025, 5:30 PMalien4u
07/24/2025, 5:31 PMHanna Johns
07/24/2025, 5:31 PMalien4u
07/24/2025, 5:32 PMHanna Johns
07/24/2025, 5:32 PMAnthony OConnor
07/24/2025, 5:39 PMHanna Johns
07/24/2025, 5:40 PMAnthony OConnor
07/24/2025, 5:40 PMAnthony OConnor
07/24/2025, 5:40 PMAnthony OConnor
07/24/2025, 5:40 PMHanna Johns
07/24/2025, 5:45 PMAnthony OConnor
07/24/2025, 5:50 PMform.clientScriptModulePath ='./TSOL - Commercial User.js';
Hanna Johns
07/24/2025, 5:51 PMHanna Johns
07/24/2025, 5:53 PMAnthony OConnor
07/24/2025, 5:54 PMHanna Johns
07/24/2025, 5:55 PMAnthony OConnor
07/24/2025, 5:55 PMAnthony OConnor
07/24/2025, 5:56 PMHanna Johns
07/24/2025, 5:58 PMAnthony OConnor
07/24/2025, 5:58 PMAnthony OConnor
07/24/2025, 5:59 PMHanna Johns
07/24/2025, 5:59 PMAnthony OConnor
07/24/2025, 6:00 PMAnthony OConnor
07/24/2025, 6:01 PMAnthony OConnor
07/24/2025, 6:01 PMAnthony OConnor
07/24/2025, 6:03 PMHanna Johns
07/24/2025, 6:03 PMAnthony OConnor
07/24/2025, 6:04 PMHanna Johns
07/24/2025, 6:06 PMHanna Johns
07/24/2025, 6:08 PMAnthony OConnor
07/24/2025, 6:10 PMHanna Johns
07/24/2025, 6:11 PMHanna Johns
07/24/2025, 6:12 PMAnthony OConnor
07/24/2025, 6:13 PMAnthony OConnor
07/24/2025, 6:13 PMHanna Johns
07/24/2025, 6:14 PMAnthony OConnor
07/24/2025, 6:14 PMHanna Johns
07/24/2025, 6:15 PMAnthony OConnor
07/24/2025, 6:15 PMHanna Johns
07/24/2025, 6:16 PMAnthony OConnor
07/24/2025, 6:18 PMHanna Johns
07/24/2025, 6:20 PMAnthony OConnor
07/24/2025, 6:21 PMAnthony OConnor
07/24/2025, 6:21 PMAnthony OConnor
07/24/2025, 6:21 PMHanna Johns
07/24/2025, 6:22 PMAnthony OConnor
07/24/2025, 6:23 PMAnthony OConnor
07/24/2025, 6:24 PMHanna Johns
07/24/2025, 6:26 PMAnthony OConnor
07/24/2025, 6:26 PMAnthony OConnor
07/24/2025, 6:45 PMform
might be your issue...
I've just renamed the form variable to be thisForm instead
and removed the commented out stuff that was just noise
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(['N/ui/serverWidget', 'N/log'], (serverWidget, log) => {
/**
* Before Load event - adds the Commercial Invoice button
* @param {Object} context - Script context
*/
const beforeLoad = (context) => {
try {
log.debug('User Event Script', 'Starting beforeLoad');
// Only add button on VIEW mode
if (context.type !== context.UserEventType.VIEW) {
log.debug('User Event beforeLoad', 'Not VIEW mode, exiting');
return;
}
const thisForm = context.form;
const salesOrderId = context.newRecord.id;
log.debug('User Event beforeLoad', 'Processing Sales Order ID: ' + salesOrderId);
// Attach the client script to the form
thisForm.clientScriptModulePath = './TSOL - Commercial Client.js'; // Path to your client script file
// Add the Commercial Invoice button
thisForm.addButton({
id: 'custpage_print_commercial_invoice',
label: 'Print Commercial Invoice',
functionName: 'printCommercialInvoice' // This calls the client script function
});
log.debug('User Event beforeLoad', 'Commercial Invoice button added successfully');
} catch (error) {
log.error('User Event beforeLoad Error', {
message: error.message,
stack: error.stack
});
}
};
return {
beforeLoad
};
});
Anthony OConnor
07/24/2025, 6:48 PMTyler Timm
07/30/2025, 5:04 AM