Sciuridae54696d
04/25/2022, 1:41 PMSciuridae54696d
04/25/2022, 1:41 PMrequire(['N/record','N/runtime','N/search','N/format'], function(record,runtime,search,format) {
try{
var rec = record.create({type:'salesorder',isDynamic:true});
var jsonObj = {
entity: "1071",
custbody_pm_so_src_no: "A20220424004",
custbody_pm_transaction_country: "230",
trandate: "2022-03-31T07:00:00.000Z",
currency: "USD",
custbody_pm_src_pmt_code: 24,
custbody_pm_so_pay_on_ship: true,
custbody_pm_src_type: 2,
externalid: "A20220424004",
location: "45",
item: {
6941448625643: {
item: 633,
quantity: 12,
custcol_pm_amso_amount: 10,
custcol_pm_amso_discountamount: 0,
amount: 10,
tax1amt: 0.9,
custcol_pm_amso_asin: "6941448625643",
custcol_pm_amso_original_qty: 1,
rate: 0.8333333333333334,
isclosed: true
}
}
};
for(var fld in jsonObj){
if (fld!="item") {
var val = jsonObj[fld];
if (fld=="trandate") {
var val = format.parse({value:jsonObj[fld],type:format.Type.DATE});
}
if (fld=="currency") {
rec.setText({fieldId:fld,text:val});
}else {
rec.setValue({fieldId:fld,value:val});
}
}
}
for(var item in jsonObj["item"]){
rec.selectNewLine({sublistId:'item'});
var itemObj = jsonObj["item"][item];
for(var col in itemObj){
rec.setCurrentSublistValue({sublistId:'item',fieldId:col,value:itemObj[col]});
}
rec.commitLine({sublistId:"item"});
}
var soId = rec.save();
/*
var soId = rec.save({
enableSourcing: true,
ignoreMandatoryFields: true
});*/
var abc = 1;
} catch (e) {
var scriptId = runtime.getCurrentScript().id;
log.error('ERROR:'+scriptId+':fn:'+runtime.executionContext, JSON.stringify({type: e.type,name: e.name,message: e.message,stack: e.stack,cause: JSON.stringify(e.cause),id: e.id}));
}
});
Sciuridae54696d
04/25/2022, 1:41 PM{
"type": "error.SuiteScriptError",
"name": "INVALID_NUMBER",
"message": "You entered \"null\" into a field where a numeric value was expected. Please go back and change this value to a number.",
"stack": [
"<anonymous>(N/record/recordService.js)",
"<anonymous>(adhoc$-1$debugger.user:59)",
"<anonymous>(adhoc$-1$debugger.user:1)"
],
"cause": "{\"type\":\"internal error\",\"code\":\"INVALID_NUMBER\",\"details\":\"You entered \\\"null\\\" into a field where a numeric value was expected. Please go back and change this value to a number.\",\"userEvent\":null,\"stackTrace\":[\"<anonymous>(N/record/recordService.js)\",\"<anonymous>(adhoc$-1$debugger.user:59)\",\"<anonymous>(adhoc$-1$debugger.user:1)\"],\"notifyOff\":false}",
"id": ""
}
Sciuridae54696d
04/25/2022, 1:43 PMSciuridae54696d
04/25/2022, 1:46 PMwarning UPC123 Item: You have only 0 available for commitment at this location (0 back ordered, 0 on order). 2022-04-25 21:45:22.527
I also see this in the debugger, but I don't think it's anythingbattk
04/25/2022, 2:12 PMbattk
04/25/2022, 2:12 PMSciuridae54696d
04/25/2022, 2:22 PMbattk
04/25/2022, 2:27 PMbattk
04/25/2022, 2:27 PMSciuridae54696d
04/25/2022, 2:31 PM