I'm getting an invalid_number error, and I'm not s...
# suitescript
s
I'm getting an invalid_number error, and I'm not sure what it is. Will post debugger snippit in the replies.
Copy code
require(['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}));
  }
});
Copy code
{
  "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": ""
}
There are no other workflows or client or user event scripts
Copy code
warning	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 anything
b
whats the tax setup like?
its unusual to use tax1amt with USD
s
hey @battk , so tax setup we're using legacy tax. Tax schedule is set on the items, defaults to a tax code. Tax lookup switched on, but we still manually override the tax. you could be right, this customer is US configured with a Texas Nexus, but I also have this issue with CA... We're on one world, so far, the other countries seems ok?
b
in general dont set fields you wouldnt set in the ui
remove tax1amt
keanu thanks 1
1
s
yup, that has indeed solved the invalid number, thanks battk!! awesome!!!!
154 Views