Sample body package:
{"entity":"123","recordtype":"salesorder","item":[{"item":"10","quantity":"1"},{"item":"11","quantity":"1"}]}
Note: This article requires existing knowledge of programming and RESTLets.
function createRecord(datain){
var err = new Object();
// Validate if mandatory record type is set in the request
if (!datain.recordtype)
{
err.status = "failed";
err.message= "missing recordtype";
return err;
}
var record = nlapiCreateRecord(datain.recordtype);
for (var fieldname in datain)
{
if (datain.hasOwnProperty(fieldname))
{
if (fieldname != 'recordtype' && fieldname != 'id')
{
var value = datain[fieldname];
if (value && typeof value != 'object') // process non-item fields
{
record.setFieldValue(fieldname, value);
}
if (value && typeof value == 'object') // process line item objects
{
for (var itemobject in value)
{
record.selectNewLineItem('item');
var lineitemobject= value[itemobject];
for (var lineitemfieldname in lineitemobject )
{
var lineitemfieldvalue = lineitemobject[lineitemfieldname];
record.setCurrentLineItemValue('item',lineitemfieldname,lineitemfieldvalue);
}
record.commitLineItem('item');
}
}
}
}
}
var recordId = nlapiSubmitRecord(record);
return recordId;
}
What library should I be using when deploying the script? I am getting when I try it
ReplyDelete"message": "ReferenceError: \"Ext\" is not defined. (app-all.js#1)."