I am not a suitescript coder. I have JS knowledge. A while back i came across a script which would create an SO for me. The script was similar to the one attached, just that it had the else condition for when "Typeof Value=='object'
function getItems(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];
nlapiLogExecution('DEBUG', fieldname);
// ignore other type of parameters
if (value && typeof value != 'object')
{
record.setFieldValue(fieldname, value);
}
}
}
}
var recordId = nlapiSubmitRecord(record);
nlapiLogExecution('DEBUG','id='+recordId);
// returns the created record in JSON format
var nlobj = nlapiLoadRecord(datain.recordtype,recordId);
return nlobj;
}
Can someone help me fill the else section where I would process the Items array when the recordtype would be 'salesorder'
Greatly appreciate your help.
Thanks