0
votes

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

1
What kind of a script is this? Is this a restlet? How is it being hit? To give proper solutions we really need full context - TMann
It is a restlet and will be hit from an external web service. - tkansara

1 Answers

0
votes

Something like this:

nlapiSelectNewLineItem('item');
nlapiSetCurrentLineItemValue('item', 'item', 380, true, true);
nlapiSetCurrentLineItemValue('item', 'location', 102, true, true);
nlapiCommitLineItem('item');