背景

我们偶尔会使用一些自定义字段的Filter关系来控制其在具体页面的下拉列表的可选值,比如下图所示:
image.png
image.png
这一切都很美好,因为他跟我们期待都结果是一样的。

然鹅,如果我们尝试用工作流去修改这个字段都话,无论咋整都会包如下的错误:
image.png
Invalid Reference Key - 图4Invalid custbody*_type reference key 7 for custbody*ble_civ
这玩意儿困扰我多时,直到在SuiteAnswer上面看到如下解释。

Applies To

Product: NetSuite 2019.2

Scenario

Workflow is not filtering custom fields’ selection according to its settings in the User Interface.

Solution

There is difference between UI and Workflow behavior and the way how custom fields show filtered results:

  • Custom field in UI shows results according to Filtering settings
  • The same field in Workflow shows all results and is not filtered

There may be situations where two or more custom fields are linked between each other and filtered on one form. As a result, invalid combinations can be chosen in Workflow.
Note: The current functionality is by design. In this particular case, Workflow can be compared to scripted program. If exact values are set in a code and ran, the user will face some invalid combinations - because it is set before the actual process is evaluated and cannot react to user interaction.

结论

这里最大的问题不是我这个过滤条件没有带过来,而是在数据提交的时候,NS在工作流这边的验证机制不会把Form上设置的值给带过来,而这个字段依赖那些值,所以这里无论如何都会报invalid reference的错误。

我打个比方,字段A(List/Record指向一个自定义记录)有三个限制条件,要求单据上X勾选,Y和Z不勾选。在FORM上是可以直接设置XYZ这三个字段的勾选状态的,所以进入特定表单列表会按照我们期待的显示。

但是到了工作流就不一样了,通过FORM预置的这些勾选字段的值全部是空,加入全空的条件对应的列表值是空列表,那么这个时候这个字段你提交任何值都是不合法的,因为filter验证之后列表为空。