Jack R
03/25/2021, 2:46 PMbattk
03/25/2021, 3:07 PMJack R
03/25/2021, 3:25 PM/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define( [
‘SuiteScripts/Globals/DAO/daoLocation’,
‘N/ui/dialog’,
],
function(daoLocation,dialog) {
function pageInit(context) {
}
function fieldChanged(context) {
var currentRecord = context.currentRecord;
var _fieldId = context.fieldId;
var fieldValue = currentRecord.getValue(_fieldId);
if (_fieldId == ‘custbody_pl_storepickup’) {
var intLocationId = currentRecord.getValue(‘location’);
if(intLocationId == ‘’) {
alert(‘Pick a store first.’);
currentRecord.setValue({
fieldId: ‘custbody_pl_storepickup’,
value: false,
ignoreFieldChange: true,
forceSyncSourcing: true
});
} else {
if(fieldValue == true) {
var objLocation = daoLocation.getObj(intLocationId);
if(objLocation.taxItemId != ‘’) {
currentRecord.setValue({
fieldId: ‘shipaddresslist’,
value: -2, // -2 == - Custom -
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘attention’,
value: ‘Store Pick Up ’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘addr1’,
value: objLocation.address1,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘addr2’,
value: objLocation.address2,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘city’,
value: objLocation.city,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘state’,
value: objLocation.state,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘zip’,
value: objLocation.zip,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘country’,
value: objLocation.country,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘shipaddress’,
value: ‘Store Pick Up ’ + ' ' + objLocation.address1 + ' ' + objLocation.city + ' ' + objLocation.state + ' ' + objLocation.zip + ' ' + objLocation.country,
forceSyncSourcing: true,
ignoreFieldChange: false
});
}
} else {
currentRecord.setValue({
fieldId: ‘shipaddresslist’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘attention’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘addr1’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘addr2’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘city’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘state’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘zip’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘country’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
var boIsTaxable = currentRecord.getValue(‘isTaxable’);
if(boIsTaxable) {
currentRecord.setValue({
fieldId: ‘taxitem’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
currentRecord.setValue({
fieldId: ‘taxrate’,
value: ‘’,
ignoreFieldChange: true,
forceSyncSourcing: true
});
}
currentRecord.setValue({
fieldId: ‘shipaddress’,
value: ‘’,
forceSyncSourcing: true
});
dialog.alert({title: ‘ALERT!’, message: ‘Since you selected Store Pick Up then unselected this option - you will have to reselect the desireed ship to address for this order.’});
}
}
}
}
return {
pageInit : pageInit,
fieldChanged : fieldChanged
};
});battk
03/25/2021, 3:27 PMbattk
03/25/2021, 3:27 PMbattk
03/25/2021, 3:28 PMJack R
03/25/2021, 3:29 PMbattk
03/25/2021, 3:31 PM