I am getting an error
{'error': {'code': 'JS_EXCEPTION', 'message': 'org.mozilla.javascript.EcmaError: TypeError: Cannot find function selectNewLine in object standard record. (/SuiteScripts/NS Tests 2.js#67)'}}
on trying to create a sales order record using a restlet.
My code below. How can I get it working?
/** * @NApiVersion 2.0 * @NScriptType Restlet * @NModuleScope SameAccount */ define([ 'N/record', ], function(record) { function doPost(data){ var recordObj = record.create({ type: "salesorder", is_dynamic: true }); var customer = data.customer; var tech = data.tech; var items = data.items; recordObj.setValue({ fieldId:'entity', value:customer }); recordObj.setValue({ fieldId:'salesrep', value:tech }); for (i = 0; i < items.length; i++) { recordObj.selectNewLine({ sublistId: 'item' }); recordObj.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: items[i][0] }); recordObj.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: items[i][1] }); recordObj.commitLine({ sublistId:'item' }); } var recordId = recordObj.save({ enableSourcing: false, ignoreMandatoryFields: false }); return recordId; } return {post:doPost}; });
Advertisement
Answer
Your is_dynamic
should be isDynamic
in record.create()
.