I have created RESTlet that will accept a series of SALES ORDER internal ids and from them create CASH SALES using nlapiTransformRecord to go from SALES ORDER to CASH SALE (code at below message).
In testing my RESTLET I receive the following error message:
{ "error": { "code": "USER_ERROR", "message": "You must enter at least one line item for this transaction." } }However when I go into NetSuite the system created the CASH SALE based on the given SALES ORDER with all the appropriate items.Additionally, when I view the CASH SALE that was created it listing the items in the item list as BACKORDERED when there is clearly enough inventory.I'm looking for answers as to why I would be receiving the error and why NetSuite is setting items on the CASH SALE to backordered. Any help would be appreciated. function add_updateCashSale(datain){ var recordtype = datain.recordtype; var status = datain.status; var customform = parseInt(datain.customform); var createdfrom = parseInt(datain.createdfrom); var cashsale; var cashsaleId; if(status == 'create'){ nlapiLogExecution('DEBUG','BEGIN CREATION OF CASH SALES','******************** BEGIN CREATION OF CASH SALES ********************'); for(fieldname in datain){ if(datain.hasOwnProperty(fieldname)){ cashsale = nlapiTransformRecord("salesorder",parseInt(createdfrom),"cashsale",{'customform':159}); cashsale.setFieldValue('chargeit','F'); cashsale.setFieldValue('ccapproved','T'); cashsaleId = nlapiSubmitRecord(cashsale); nlapiLogExecution('DEBUG','CASH SALE CREATED','CASH SALE CREATED, ID: '+cashsaleId); } } nlapiLogExecution('DEBUG','END CREATION OF CASH SALES','******************** END CREATION OF CASH SALES ********************'); } return {"NSID": cashsaleId}; }