Suitescript - 在销售订单表格上获取并显示运费

Suitescript - Fetch and display shipping cost on sales order form

有没有办法像 NetSuite Web 表单那样在创建销售订单时显示运费?据我所知,如果设置为固定费率、运费 table 和其他要考虑的规则(如最高费率等),则每个运输项目都有一个设置。

那么,我应该改为手动计算吗?或者别的什么?

如果您使用的是 SuiteScript,请使用如下所示的 nlapiCreateRecord 方法:

var record = nlapiCreateRecord('salesorder', {'recordmode': 'dynamic'});

Setting recordmode to dynamic is important otherwise the computations will always be 0.

接下来,使用其内部 ID 设置送货方式。

record.setFieldValue('shipmethod', input.shipping_method);

接下来,遍历 json 数据中的项目列表,然后在进入下一次迭代之前提交行项目:

// sample json data on one item (all attributes are internal IDs except quantity)
[
    {"id":6657,"quantity":2,"units":16,"price":1,"taxcode":22},
    {"id":3941,"quantity":1,"units":16,"price":1,"taxcode":22}
]

// start
    record.selectNewLineItem('item');
    record.setCurrentLineItemValue('quantity', item.quantity);
    // duplicate setCurrentLineItemValue and change the parameters to 
    // units, price, taxcode respectively
    record.commitLineItem('item');
// end

最后,您可以使用 getFieldValue 方法获取运费:

record.getFieldValue('shippingcost');

请注意,您还可以获得小计、税金和总计(或总体总成本)的值。