NetSuite:从SuiteScript 2.0中的销售订单获取shipcity

时间:2016-05-25 20:37:09

标签: javascript netsuite suitescript

如果我使用下面的代码加载销售订单,我该如何获得shipcity。请注意,如果您转储对象(salesOrder),您将看到没有shipcity。奇怪的是,shipzipshipstateshipcountry有自己的字段,但shipcity没有。我也试过billcity,但无济于事。这似乎是一个很大的脱节。 shipcity应该像在UI中一样Fort Wayne,但2.0 API不返回任何内容

// load up a sales order from a Fort Worth customer
var salesOrder = record.load({
   type: record.Type.SALES_ORDER,
   id: salesOrderId,
   isDynamic: true
});

// these work fine
salesOrder.getValue("shipcountry") = "US"
salesOrder.getValue("shipstate") = "IN"
salesOrder.getValue("shipzip") = "46804"

// none of the following work when it should say "Fort Wayne"
salesOrder.getValue("shipcity") = Null
salesOrder.getValue({ fieldId: "shipcity" }) = Null
salesOrder.getText("shipcity") = Null

1 个答案:

答案 0 :(得分:1)

我刚刚证实了这一点。使用SS1.0,我们可以为“城市”提供价值。但由于某些原因没有SS2.0。因此,让我们使用&n;&n;' N / search'模块。您可以创建搜索或执行查找。但我建议你使用查找,因为你只是在标题上获得价值。请尝试以下示例代码:

顺便说一下,请硬编码类型的值,不要使用' search.Type.SALES_ORDER'。由于某些原因,它会出错。

require(
[
    'N/search'
], function(search)
{
var objFieldLookUp = search.lookupFields(
    {
        type : 'salesorder',
        id : 34826,
        columns :
            [
                    'shipcountry', 'shipstate', 'shipzip', 'shipcity'
            ]
    });

var stCountry = objFieldLookUp["shipcountry"];
var stState = objFieldLookUp["shipstate"];
var stZip = objFieldLookUp["shipzip"];
var stCity = objFieldLookUp["shipcity"];
});