如何在Netsuite中从工作订单创建转储订单?

时间:2019-06-04 22:52:52

标签: javascript netsuite

我是脚本新手,我想知道我的代码是否正确,以便在Netsuite中输入WO时就可以创建TO:

define(['N/record',], function (record) {  function afterSubmit(context) {
if(context.type == 'delete'){
    log.debug('Exiting script', '...');
    return;
}
try{
var so = record.load({
    type:'workorder',
    id:context.newRecord.id
});
var so_items = so.getLineCount({sublistId:'item'});


// Create new Transfer Order if Record is On Create.
 var to_record = record.create({
    type:'transferorder',
    isDynamic:true
});

to_record.setValue({fieldId:'customform', value:136});
to_record.setValue({fieldId:'class', value:so.getValue('class')});
to_record.setValue({fieldId:'transferlocation', value:so.getValue('location')});

setLineItemsOnTO(so_items, to_record, so);

to_record.setValue({fieldId:'custbody_related_record', value:context.newRecord.id});
so.setValue({fieldId:'custbody_related_record', value:to_record.save()});
so.setValue({fieldId:'orderstatus',value:'B'});
so.save({ignoreMandatoryFields:true});
} catch(e){
    log.debug('Error Loading Record' + context.newRecord.id, e);
    return;     }

1 个答案:

答案 0 :(得分:1)

没有地方可以保存已创建的转储单;您需要调用to_record.save()才能将其提交到数据库。