Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

NetSuite Add Line Item to a Sales Order in afterSubmit

function afterSubmit(type)
{
    if(type == 'create' || type == 'edit')
    {
        var record = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId()); //Load the record

        //Loop to all sublist item
        var count = record.getLineItemCount('item');
        for(var i = 1; i <= count; i++)
        {
            var item = record.getLineItemValue('item', 'item', i); //This will return the internal id of the item
            if(item == 100) //Item is equal to 100; insert one item
            {
                record.insertLineItem('item', i);
                record.setLineItemValue('item', 'item', i, 200); //Repair Cost internal id
                record.setLineItemValue('item', 'quantity', i, 1); //You should put some quantity; depending on your account setup all required fields should be set here.
            }
        }

        //Submit the changes
        nlapiSubmitRecord(record, true);
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #NetSuite #Add #Line #Item #Sales #Order #afterSubmit
ADD COMMENT
Topic
Name
5+9 =