首页 > 解决方案 > CASE WHEN Formula - NetSuite

问题描述

I'm trying to get results for a field with Formula (Text). The idea is - if the subsidiary = A, then show field 1. If subsidiary = B, then show field B. (please see the formula below). For some reason, I didn't get any results. Both fields are transaction column fields. When I'm testing only the fields (without formula - just the name of the field) they work.

Type of the Saved Search is: Transaction Main Line is: False

Case when {subsidiary}='A' THEN {field1} when {subsidiary}='B' THEN {fieild2} END

For the records which belong to the Subsidiary A field 2 is empty and for the Subsidiary B - field 1 is empty accordingly. Therefore I would like if the Subsidiary is A to populate field 1 and if it's B to populate filed 2. Can you please advise how to achieve this?

Thank you in advance.

标签: casefieldformulanetsuitecase-when

解决方案


{subsidiary}字段期望整个父子层次结构进行匹配,因此“Honeycomb Holding Inc. : Honeycomb Mfg.” . 您可以使用 `{subsidiarynohierarchy} 来匹配交易所在的基本子公司名称(即Honeycomb Mfg.)。这个公式应该有效:

case 
    when {subsidiarynohierarchy} = 'Honeycomb Mfg.' then {field1}  
    when {subsidiarynohierarchy} = 'test sub' then {field2}  
end

如果没有ELSE提供子句并且没有找到匹配项,它将返回一个空结果。

对于属于子公司 A 的记录,字段 2 为空,对于子公司 B - 字段 1 相应地为空。

如果,正如您所提到的,这些字段仅为给定的子公司填充,那么您可以将公式简化为:

coalesce({field1}, {field2})

这将返回第一个非空值,因此如果子公司 A 已field1填充,它将返回field1。如果子公司 B 为field1空且field2已填充,它将返回field2


推荐阅读