【问题标题】:How to access Country list in Netsuite?如何在 Netsuite 中访问国家/地区列表?
【发布时间】:2017-06-15 18:01:48
【问题描述】:

我在 Netsuite 中使用 SuiteScript 2.0。国家名单可在 设置 > 公司 > 国家。在当前版本中,我还没有找到一种方法来获取添加到自定义 Suitelets 中的国家和州/省下拉列表。

如何从 Netsuite Suitescripts 访问此列表?

【问题讨论】:

  • this 有帮助吗?
  • 不。我需要从我的套件脚本中加载该国家/地区列表。(例如使用记录模块)。

标签: netsuite suitescript


【解决方案1】:

可能有更直接的方法来执行此操作,但您可以开始创建客户记录、访问地址对象并获取可用的选择选项。

var custRec = record.create({ type: record.Type.CUSTOMER, isDynamic: true });
var custSubrec = custRec.getCurrentSublistSubrecord({ sublistId: 'addressbook', fieldId: 'addressbookaddress' });
var countryFieldObj = custSubrec.getField({ fieldId: 'country' });
var countryList = countryFieldObj.getSelectOptions();

【讨论】:

    【解决方案2】:

    这里没有任何模块或枚举。 SuiteScript 使用 ISO 标准的两个字母 (ALPHA-2) 国家/地区代码。 http://www.nationsonline.org/oneworld/country_code_list.htm

    【讨论】:

      【解决方案3】:

      为名为 customsearch_customercountry 的客户记录创建已保存搜索,其中条件为空,结果包含您想要的字段(包括国家/地区示例)。保存的搜索将被加载并包含使用 customerId 作为变量的过滤器,该变量取自或从您的代码前面的句子中填充。 脚本如下:

      var country_search = search.load({
        id: "customsearch_customercountry",
      });
      var filterArray = [];
      filterArray.push(["internalid", "is", customerId]);
      country_search.filterExpression = filterArray;
      
      var searchResult = country_search.run().getRange({
        start: 0,
        end: 1,
      });
      log.debug({
        title: "Execute Search ",
        details: "ResultSet length: " + searchResult.length,
      });
      if (searchResult.length > 0) {
        var country = searchResult[0].getText({
          name: "Country",
        });
        log.debug({
          title: "Execute Search ",
          details: "ResultSet found with country: " + country,
        });
      }
      
      

      注意:您必须使用.getText() 函数来检索国家/地区结果的文本值。如果您只需要国家代码,请使用.getValue() 而不是

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-03-08
        • 2017-10-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-27
        • 1970-01-01
        相关资源
        最近更新 更多