尝试使用以下方法转换NetSuite销售订单
var fulfillment = record.transform({
fromType: record.Type.SALES_ORDER,
fromId: currentRecord.id,
toType: record.Type.ITEM_FULFILLMENT,
isDynamic: true
});
获取错误"USER_ERROR“、”消息“:”您必须至少为该事务输入一行项。“
实现包含7个行项,但是在fulfillment.save()之后,它返回没有添加到实现中的行项的错误。
是否有一种方法来选择要实现的行?想一想,在查看销售订单时,单击“履行”,然后单击一个复选框,将哪些行项包含在该实现中。
谢谢
发布于 2021-07-22 21:22:48
有一个事务列字段,名为"itemreceive“。这个“item接收”字段等效于在UI中的Item itemreceive页面上找到的“完全”复选框。下面的代码应该可以工作
//transform SO to create a new Item fulfillment
var fulfillment = record.transform({
fromType: record.Type.SALES_ORDER,
fromId: currentRecord.id,
toType: record.Type.ITEM_FULFILLMENT,
isDynamic: true
});
//get line count of newly created fulfillment
var lineCount = fulfillment.getLineCount({
sublistId: 'item'
});
//for each line set the "itemreceive" field to true
for (var i = 0; i < lineCount; i++) {
fulfillment.selectLine({
sublistId: 'item',
line: i
});
fulfillment.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'itemreceive',
value: true
});
//set other relevant sublist fields
fulfillment.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'fieldId',
value: 'value'
});
fulfillment.commitLine({
sublistId: 'item'
});
}
//set any other relevant itemreceive fields
itemreceive.setValue({
filedId: 'fieldId',
value: 'value'
});
//save the newly created itemreceive
var itemreceiveId = itemreceive.save({
enableSourcing: true, //optional, defaul is false
ignoreMandatoryFields: true //optional, defaul is false
});
发布于 2021-07-22 21:21:46
如果销售订单中有可实现的行,则可能会出现未选中的“履行”复选框。这是通过设置->会计->会计首选项、订单管理选项卡、履行部分中的“默认项到零接收/履行”复选框控制的。
考虑到在您的帐户中的效果,它可能会被检查,因此,在默认情况下,如果您只创建和保存一个项目实现,行将不会得到满足。
通常,在编写实现脚本时,我将迭代行并执行如下操作:
var shouldFulfill = someLogic();
itemFulfillment.setSublistValue({sublistId:'item', fieldId:'itemreceive', line:idx, value:shouldFufill});
或者像你的例子中的isDynamic:true
itemFulfillment.setCurrentSublistValue({sublistId:'item', fieldId:'itemreceive', line:idx, value:shouldFufill});
https://stackoverflow.com/questions/68490597
复制相似问题