📜  NetSuite 在 afterSubmit 中将行项目添加到销售订单 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:29.093000             🧑  作者: Mango

代码示例1
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);
    }
}