razer456
05/04/2022, 4:52 PMEric B
05/04/2022, 4:53 PMrazer456
05/04/2022, 4:53 PMrazer456
05/04/2022, 4:54 PMEric B
05/04/2022, 4:55 PMEric B
05/04/2022, 4:55 PMrazer456
05/04/2022, 5:11 PM{
type: "error.SuiteScriptError",
name: "UNEXPECTED_ERROR",
message: "An unexpected SuiteScript error has occurred",
stack: [
"Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at Object.afterSubmit (/SuiteScripts/GBS_UE_setCustomerAndPriceLevel.js:271:20)"
],
cause: {
type: "internal error",
code: "UNEXPECTED_ERROR",
details: "An unexpected SuiteScript error has occurred",
userEvent: null,
stackTrace: [
"Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at Object.afterSubmit (/SuiteScripts/GBS_UE_setCustomerAndPriceLevel.js:271:20)"
],
notifyOff: false
},
id: "",
notifyOff: false,
userFacing: true
}
razer456
05/04/2022, 5:12 PMrazer456
05/04/2022, 5:12 PMbattk
05/04/2022, 5:15 PMbattk
05/04/2022, 5:16 PMbattk
05/04/2022, 5:16 PMbattk
05/04/2022, 5:16 PMbilladdrSubrecord.setValue({
fieldId: "country",
value: billCountry || ""
});
doesnt mean much to usbattk
05/04/2022, 5:17 PMbattk
05/04/2022, 5:17 PMbattk
05/04/2022, 5:17 PMrazer456
05/04/2022, 5:18 PMrazer456
05/04/2022, 5:18 PMrazer456
05/04/2022, 5:18 PMrazer456
05/04/2022, 5:19 PMrazer456
05/04/2022, 5:19 PMrazer456
05/04/2022, 5:19 PMbattk
05/04/2022, 5:21 PMbattk
05/04/2022, 5:22 PMbattk
05/04/2022, 5:23 PMrazer456
05/04/2022, 5:25 PMrazer456
05/04/2022, 5:25 PMrazer456
05/04/2022, 5:25 PMrazer456
05/04/2022, 5:26 PMrazer456
05/04/2022, 5:26 PMrazer456
05/04/2022, 5:27 PMrazer456
05/04/2022, 5:27 PMbattk
05/04/2022, 5:29 PMbattk
05/04/2022, 5:30 PMbattk
05/04/2022, 5:30 PMbattk
05/04/2022, 5:30 PMrazer456
05/04/2022, 5:30 PMrazer456
05/04/2022, 5:42 PMrazer456
05/04/2022, 5:42 PMrazer456
05/04/2022, 5:42 PMrazer456
05/04/2022, 5:42 PMbattk
05/04/2022, 5:43 PMrazer456
05/04/2022, 5:48 PM/**
*@NApiVersion 2.1
*@NScriptType UserEventScript
*/
define(["N/record", "N/search"], function (record, search) {
function afterSubmit(context) {
try {
var recordLoadsoid = context.newRecord;
var recordId = recordLoadsoid.id;
log.debug({
title: "recordId",
details: recordId
});
var recordLoadso = record.load({
type: record.Type.SALES_ORDER,
id: recordId
});
var {
itemLineCount,
getShopifyCustomer,
getCustomerShipAddress,
getCustomerShipTo,
getCustomerBillTo,
getCustomerBillAddress
} = getExistingRecordData(recordLoadso);
if (
getShopifyCustomer == 1793051 ||
getShopifyCustomer == "1793051" ||
getShopifyCustomer == 1775805 ||
getShopifyCustomer == "1775805"
) {
var {
shipCountry,
shipisresidential,
shipattention,
shipaddressee,
shipaddrphone,
shipaddr1,
shipaddr2,
shipcity,
shipstate,
shipzip
} = getShipData(recordLoadso);
if (getShopifyCustomer == 1793051 || getShopifyCustomer == "1793051") {
setShip(
recordLoadso,
shipCountry,
shipisresidential,
shipattention,
shipaddressee,
shipaddrphone,
shipaddr1,
shipaddr2,
shipcity,
shipstate,
shipzip,
getCustomerShipTo
);
}
recordLoadso.save();
}
} catch (e) {
log.debug({
title: "e",
details: e
});
}
}
function setShip(
recordLoadso,
shipCountry,
shipisresidential,
shipattention,
shipaddressee,
shipaddrphone,
shipaddr1,
shipaddr2,
shipcity,
shipstate,
shipzip,
getCustomerShipTo
) {
try {
recordLoadso.setValue({
fieldId: "shipaddresslist",
value: -2
});
var shipaddrSubrecord = recordLoadso.getSubrecord({
fieldId: "shippingaddress"
});
log.debug("shipCountry", shipCountry);
shipaddrSubrecord.setValue({
fieldId: "country",
value: shipCountry
});
log.debug(
"shipCountry",
shipaddrSubrecord.getValue({
fieldId: "country"
})
);
} catch (err) {
log.debug({
title: "errr in setship",
details: err
});
}
}
function getShipData(recordLoadso) {
try {
var shipaddrSubrecord = recordLoadso.getSubrecord({
fieldId: "shippingaddress"
});
return {
shipCountry: shipaddrSubrecord.getValue({
fieldId: "country"
}),
shipisresidential: shipaddrSubrecord.getValue({
fieldId: "isresidential"
}),
shipattention: shipaddrSubrecord.getValue({
fieldId: "attention"
}),
shipaddressee: shipaddrSubrecord.getValue({
fieldId: "addressee"
}),
shipaddrphone: shipaddrSubrecord.getValue({
fieldId: "addrphone"
}),
shipaddr1: shipaddrSubrecord.getValue({
fieldId: "addr1"
}),
shipaddr2: shipaddrSubrecord.getValue({
fieldId: "addr2"
}),
shipcity: shipaddrSubrecord.getValue({
fieldId: "city"
}),
shipstate: shipaddrSubrecord.getValue({
fieldId: "state"
}),
shipzip: shipaddrSubrecord.getValue({
fieldId: "zip"
})
};
} catch (err) {
log.debug({
title: "err in get ship data",
details: err
});
}
}
return {
afterSubmit: afterSubmit
};
});
razer456
05/04/2022, 5:51 PMbattk
05/04/2022, 5:52 PMrazer456
05/04/2022, 5:56 PM/**
*@NApiVersion 2.1
*@NScriptType UserEventScript
*/
define(["N/record", "N/search"], function (record, search) {
function afterSubmit(context) {
try {
var recordLoadsoid = context.newRecord;
var recordId = recordLoadsoid.id;
log.debug({
title: "recordId",
details: recordId
});
var recordLoadso = record.load({
type: record.Type.SALES_ORDER,
id: recordId
});
setShip(recordLoadso);
recordLoadso.save();
} catch (e) {
log.debug({
title: "e",
details: e
});
}
}
function setShip(recordLoadso) {
try {
var shipaddrSubrecord = recordLoadso.getSubrecord({
fieldId: "shippingaddress"
});
shipaddrSubrecord.setValue({
fieldId: "country",
value: "US"
});
log.debug(
"shipCountry",
shipaddrSubrecord.getValue({
fieldId: "country"
})
);
} catch (err) {
log.debug({
title: "errr in setship",
details: err
});
}
}
return {
afterSubmit: afterSubmit
};
});
razer456
05/04/2022, 5:57 PMrazer456
05/04/2022, 5:57 PMrazer456
05/04/2022, 5:57 PMrazer456
05/04/2022, 5:57 PMrazer456
05/04/2022, 5:57 PMbattk
05/04/2022, 6:01 PMrazer456
05/04/2022, 6:02 PMrazer456
05/04/2022, 6:03 PMrazer456
05/04/2022, 6:03 PMrazer456
05/04/2022, 6:03 PMbattk
05/04/2022, 6:04 PMbattk
05/04/2022, 6:06 PMbattk
05/04/2022, 6:09 PMrazer456
05/04/2022, 6:14 PMrazer456
05/04/2022, 6:14 PMrazer456
05/04/2022, 6:14 PMrazer456
05/04/2022, 6:14 PMrazer456
05/04/2022, 6:14 PMrazer456
05/04/2022, 6:15 PMrazer456
05/04/2022, 6:15 PM