简体   繁体   English

NetSuite SuiteScript 2.0 getSelectOptions过滤器破坏了setValue

[英]NetSuite SuiteScript 2.0 getSelectOptions filter breaks setValue

I am dumbfounded on what is happening and hoping someone can help me figure out what is happening. 我对正在发生的事情感到震惊,希望有人能帮助我弄清楚正在发生的事情。 I am using SuiteScript 2.0 and to find the internal id's of dynamic fields I am doing: 我正在使用SuiteScript 2.0并查找我正在做的动态字段的内部ID:

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

This returns the internal ID I need but when I try to call: 这将返回我需要的内部ID,但是当我尝试调用时:

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

I get an error: 我收到一个错误:

{
  "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\":\"\"}"
  }
}

The number 2 is definitely the internal ID I need. 数字2绝对是我需要的内部ID。 But it starts to get weird. 但这开始变得怪异了。 If I remove the filter and just call: 如果我删除过滤器,然后致电:

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

And then loop through the array of results and select the proper internal id I need everything works fine and it is able to set the internal id of location . 然后遍历结果数组并选择适当的内部ID,我需要一切正常,并且能够设置location的内部ID。 It seems like the filter is removing it from the location select field or something strange like that but I can't imagine that is the intended purpose of the filter. 似乎过滤器正在将其从“ location选择”字段中删除或类似的东西,但我无法想象这是过滤器的预期目的。 Is this a bug or am I using it wrong? 这是错误还是我使用错了?

Just a hunch, try running again 只是预感,请尝试再次运行

.getSelectOptions({filter: "Test Location",operator: 'is'}). .getSelectOptions({过滤器:“测试位置”,操作员:“是”})。

Then after getting the value 然后在获得价值之后

.getSelectOptions(); .getSelectOptions();

It seems like a bug, where the data object holding the available values is left filtered. 似乎是一个错误,其中保留了可用值的数据对象被过滤掉了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM