Michael McNamara
01/28/2025, 3:26 PMerictgrubaugh
01/28/2025, 3:43 PMNickSuite
01/28/2025, 4:23 PMAnthony OConnor
01/28/2025, 5:07 PMAnthony OConnor
01/28/2025, 5:08 PMAnthony OConnor
01/28/2025, 5:09 PMerictgrubaugh
01/28/2025, 5:10 PMAnthony OConnor
01/28/2025, 5:12 PMerictgrubaugh
01/28/2025, 5:15 PMMichael McNamara
01/28/2025, 6:40 PMMichael McNamara
01/28/2025, 6:40 PMerictgrubaugh
01/28/2025, 6:48 PMpageInit
handler that logs a message to the console or displays right away. You can use that message to confirm whether the Client Script is loading at all. If it is, then you can proceed to troubleshoot your code. If it's not, you might need NetSuite support.Michael McNamara
01/28/2025, 6:50 PM/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/currentRecord', 'N/record'],
/**
* @param{currentRecord} currentRecord
* @param{record} record
*/
function(currentRecord, record) {
/**
* Function to be executed after page is initialized.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.currentRecord - Current form record
* @param {string} scriptContext.mode - The mode in which the record is being accessed (create, copy, or edit)
*
* @since 2015.2
*/
function pageInit(context) {
var addRec = context.currentRecord;
var addState = addRec.getField({
fieldId: 'state'
});
var addSatateDisplay = addState.isDisabled = true;
//get
}
/**
* Function to be executed when field is changed.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.currentRecord - Current form record
* @param {string} scriptContext.sublistId - Sublist name
* @param {string} scriptContext.fieldId - Field name
* @param {number} scriptContext.lineNum - Line number. Will be undefined if not a sublist or matrix field
* @param {number} scriptContext.columnNum - Line number. Will be undefined if not a matrix field
*
* @since 2015.2
*/
function fieldChanged(context) {
var addRec = context.currentRecord;
if(context.fieldId == 'zip'){
var custState = addRec.getText({
fieldId: 'state'
})
var custZip = addRec.getText({
fieldId: 'zip'
})
if(custZip === null || custZip === '') {
addRec.setValue({
fieldId:'custrecord_ace_custom_state',
value:null
});
addRec.setValue({
fieldId:'state',
value:null
});
addRec.setValue({
fieldId:'city',
value:null
});
}
else if (custZip != '') {
addRec.setText({
fieldId:'custrecord_ace_custom_state',
text:custState
});
}
}
}
return {
pageInit: pageInit,
fieldChanged: fieldChanged
};
});
Anthony OConnor
01/28/2025, 6:54 PMerictgrubaugh
01/28/2025, 6:54 PMpageInit
and use it as stated previouslyMichael McNamara
01/28/2025, 6:55 PMerictgrubaugh
01/28/2025, 6:55 PMconsole.log()
Anthony OConnor
01/28/2025, 6:55 PMMichael McNamara
01/28/2025, 6:55 PMMichael McNamara
01/28/2025, 6:58 PMAnthony OConnor
01/28/2025, 7:03 PMvar custState = addRec.getText({
fieldId: 'state'
})
is only in the if block of code
so its not defined in the else if blockAnthony OConnor
01/28/2025, 7:04 PMAnthony OConnor
01/28/2025, 7:04 PMMichael McNamara
01/28/2025, 7:05 PMMichael McNamara
01/28/2025, 7:07 PMAnthony OConnor
01/28/2025, 7:09 PMMichael McNamara
01/28/2025, 7:10 PMAnthony OConnor
01/28/2025, 7:10 PMerictgrubaugh
01/28/2025, 7:10 PMMichael McNamara
01/28/2025, 7:11 PMerictgrubaugh
01/28/2025, 7:13 PM