首页 文章

NetSuite SuiteScript 2.0 getSelectOptions过滤器中断了setValue

提问于
浏览
0

我对发生的事情感到茫然,希望有人可以帮我弄清楚发生了什么 . 我正在使用SuiteScript 2.0并查找我正在执行的动态字段的内部ID:

var location = saleRec.getField({
    fieldId: 'location'
}).getSelectOptions({
    filter: "Test Location",
    operator: 'is'
});

这将返回我需要的内部ID,但是当我尝试调用时:

saleRec.setValue({
    fieldId: 'location',
    value: location[0].value
});

我收到一个错误:

{
  "error": {
    "code": "JS_EXCEPTION",
    "message": "{\"type\":\"error.SuiteScriptError\",\"name\":\"INVALID_FLD_VALUE\",\"message\":\"You have entered an Invalid Field Value 2 for the following field: location\",\"stack\":[\"anonymous(N/recordService)\",\"doPost(SuiteScripts/DemoProject/RESTlet1.js:124)\"],\"cause\":{\"type\":\"internal error\",\"code\":\"INVALID_FLD_VALUE\",\"details\":\"You have entered an Invalid Field Value 2 for the following field: location\",\"userEvent\":null,\"stackTrace\":[\"anonymous(N/recordService)\",\"doPost(SuiteScripts/DemoProject/RESTlet1.js:124)\"]},\"id\":\"\"}"
  }
}

数字2绝对是我需要的内部ID . 但它开始变得怪异 . 如果我删除过滤器,只需调用:

var location = saleRec.getField({
    fieldId: 'location'
}).getSelectOptions();

然后循环遍历结果数组并选择正确的内部id我需要一切正常并且它能够设置 location 的内部id . 看起来过滤器正在从 location 选择字段中移除它或类似的奇怪的东西,但我无法想象这是过滤器的预期目的 . 这是一个错误还是我使用它错了?

1 回答

  • 0

    只是预感,再试一次

    .getSelectOptions({filter:“Test Location”,operator:'is'}) .

    获得 Value 后

    .getSelectOptions();

    这似乎是一个错误,其中保留了可用值的数据对象被过滤掉了 .

相关问题